I was just noticing something in James' original note: > Example, let's say I want to create the following XML output: > > <s:test xmlns:s="testing> > <hello /> > </s:test> > > To do so, I use the following code. > > Document doc = ... create document > Element test = doc.createElementNS("testing", "test"); > test.setPrefix("s"); > test.setAttribute("xmlns:s", "testing"); > Element hello = doc.createElementNS("testing", "hello"); > test.appendChild(hello); > doc.appendChild(test); > > Run this through the DOM2Writer, and the output is: > > <s:test xmlns:s="testing" xmlns:s="testing"> > <hello /> > </s:test>
You seem to be attempting to create the "hello" element in the {testing} namespace. Is that the case? If so your XML serialization is still incorrect - it should say: <s:test xmlns:s="testing" xmlns:s="testing"> <s:hello /> </s:test> Which one did you want to have come out? Sanjiva.