Link to home
Start Free TrialLog in
Avatar of tia_kamakshi
tia_kamakshiFlag for United Arab Emirates

asked on

Saving Xml file Java

Hi,

I am working on Java, I am changing an Attribute of XML file

From the code below

But When I open the excel file in notepad.

I cannot see the changed value.

Can you please help me

Also, If I wanted to save the file with different name.

How do we do that

Please guide
public void readDijXML(File file)
            throws Exception
{
	BaseBL baseBL = new BaseBL();
	Document doc = baseBL.getXMLDocument(file);
	
	NodeList nodeLst = doc.getElementsByTagName("document");
 
	  System.out.println("Information of all employees"+nodeLst.getLength());
 
	  for (int s = 0; s < nodeLst.getLength(); s++) 
	  {
	      Node fstNode = nodeLst.item(s);
 
	      if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
 
		  Element fstElmnt = (Element) fstNode;
		NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("DDSDocValue");
		Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
 
		fstNmElmnt.setAttribute("name", "Test Attribute Changes Success");
 
	      }
 
	  }
  }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tia_kamakshi

ASKER

This looks great to me.

Thanks allot.  I will come back to you on this by tommorow.

Many Thanks again
Many Thanks
:-)