I have an XML code which fetches a node from one xml and creates a new xml out of it. the code is as follows,
parser = new DOMParser();
parser.parse(new StringReader(xml));
xmlSrcDoc = parser.getDocument();
xmldoc.setXmlVersion("1.0"); // new xml doc
xmldoc.setEncoding("UTF-8");
Element e1 = xmldoc.createElement("config");
e1.setAttribute("productVersion", "x.x");
e1.setAttribute("xmlns:abc", "http://xmlns.efg.com/xyz");
NodeList nl = xmlSrcDoc.getElementsByTagName("tag");
Node e = nl.item(0);
e1.appendChild(xmldoc.adoptNode(e));
xmldoc.appendChild(e1);
snippet of the XML:
<?xml version="1.0" encoding="UTF-8"?>
<search:config productVersion="x.x" xmlns:abc="http://xmlns.efg.com/xyz">
<search:tag>
<search:mno>
..................................
....................................
the new XML document created has the line
<search:tag xmlns:abc="http://xmlns.efg.com/xyz"> instead of
<search:tag>
is their a way to avoid the namespace getting included?
Software/Hardware used:
ASKED:
April 23, 2010 9:30 AM
UPDATED:
April 23, 2010 3:37 PM