Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Posts: 26951
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic