Hi, I am using Xerces 2.5.0 to create the following document:
<?xml version="1.0" encoding="UTF-8"?> <myns:root xmlns:myns="http://www.ascertia.com/xml/"> <myns:element1>text1</myns:element1> </myns:root> I m writting the following code to produce above document Document doc = new DocumentImpl(); Element root = doc.createElementNS("http://www.ascertia.com/xml/", "myns:root"); Element element1 = doc.createElement("myns:element1"); element1.appendChild(doc.createTextNode("text1")); root.appendChild(element1); doc.appendChild(root); Writer writer = new Writer(); /*Writer is the class provided in Xerces DOM Samples*/ try{ writer.setOutput(System.out, "UTF-8"); writer.write(doc); } catch (Exception ex) { ex.printStackTrace(); } The output of the above code is: <?xml version="1.0" encoding="UTF-8"?> <myns:root> <element1>text1</element1> </myns:root> The namespace declation i.e. xmlns:myns="http://www.ascertia.com/xml/" is missing in the output. I couldn't figure out that what is wrong in my code. Please tell me where I am doing wrong and what is the right way to create the above mentioned target document. Thanx Regards, Yasir Khan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
