0

I have an xml

<XML>
   <Client xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.34.00" ></Client>
</XML>

How to remove all the attributes in the Client tag in Java.

I used earlier

Element element = (Element) doc.getElementsByTagName("Client").item(0);
element.removeAttribute("Version");
element.removeAttribute("xmlns:xsi");

The Version attribute was removed from the Client tag. But xmlns:xsi attribute was NOT removed.

Does anybody faced any similar issue or know how to approach this problem.

Atul Yadav
  • 1,992
  • 1
  • 13
  • 15

1 Answers1

0

You should getOwnerDocument() for node "Client" and do renameNode(nodeClient,null,"Client"); NB: removeAttribute removes "xmlns:xsi", but namespace is stored in Node "Client" and can appear at Document to string regeneration moment.