Jaxp-Unable to remove an attribute permanently from document object
843834Dec 10 2003 — edited May 12 2004Hi
I have a requirement where I have to strip out an attribute called "xmlns" at the root element of my xml document.
for eg: <UserProfile xmlns="http://foo">
<ID>1234</ID>
<Name>Bob</Name>
</UserProfile>
I tried using API's
1) document.getDocumentElement.removeAttribute("xmlns")
After this my xml document look like this
<UserProfile >
<ID>1234</ID>
<Name>Bob</Name>
</UserProfile>
Also tried this..
2) Attr att=document.getDocumentElement().getAttributeNode("xmlns");
att.setValue("");
document.getDocumentElement().setAttributeNodeNS(att);
After this my xml document look like this
<UserProfile xmlns="">
<ID>1234</ID>
<Name>Bob</Name>
</UserProfile>
Irrespective of all this , when I gave the new xml document to Jaxb for processing , Jaxb complains that
unexpected root element
uri:http://foo
Though this attribute neither visible nor accessible using any DOM apis, still this attribute exists as part of this document.
Could somebody explains a little more about this behaviour or help me to resolve this..
Any feedback will be deeply appreciated,
Ranjith Pillai.