File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes xmlns = Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xmlns ="" is added after changing the value of an element" Watch "xmlns ="" is added after changing the value of an element" New topic

xmlns ="" is added after changing the value of an element

Saurabh Joshi
Ranch Hand

Joined: Nov 15, 2007
Posts: 37

I am updating a value in my XML, and xmlns="" is getting added to one of the tags.

My XML looks like this -

I use the below code to find the node and change the value -

Code for writing back to the XML file -

When the program ends, It changes the XML at desired location but adds the xmlns="" to the Header tag -

I have no clue which why is this getting added in the XML.

Kindly suggest how can I stop the addition of this xmlns="" to the Header tag.

Thanking you in anticipation.

Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

If you're going to deal with documents with namespaces, you should at least set the DocumentBuilderFactory to be namespace-aware. By default it isn't.

It also appears that you don't know much about namespaces yourself, since the correct description of your problem is that the Header element and all its children have been changed from the default namespace with namespace URI "" to being in no namespace. Find a tutorial and read up on namespaces.
I agree. Here's the link:
subject: xmlns ="" is added after changing the value of an element
Similar Threads
Adding SOAP elements through DOM
Transformer - omitting the xml header (" ?xml encoding=.. ?" )
need a point in the right direction using XMLTYPE, dbms_xmlgen.convert, dbms_xmlgen.ENTITY_DECODE
How to convert Node to a Document?
SOAP Header problem SAAJ