• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

modifying the value of the node

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can we modify the value of the node using jaxp api
suppose i have a tag
<read>Reading xml files</read>
i have to updathe value to writing xml files
i have used setNodeValue("new string")
but no use.please tell me how to resolve this
my code for writing this is document.createElement("read");
Text val= document.createTextNode("Reading xml files")
and add both of the elements to the root element
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you have this structure:
<read>Reading xml files</read>

What you have is an org.w3c.dom.Element which has a single Child Node that is of type TEXT_NODE.
SO - in order to change the value, starting with the Element, you have to get the Node with getFirstChild() then setNodeValue("the new text")

Note that if you do a getNodeValue() on the Element, you get null.

I always find the table in the Javadocs for org.w3c.dom.Node to be extremely valuable.
Bill
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic