• 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

Can an XML Node be converted to a String

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to convert an XML Node to a string?

Can this :
<root>
<child1>Me</child1>
<child2>You</child2>
</root>

be converted to:

"<root><child1>Me</child1><child2>You</child2></root>"


When I try root.getChildNodes().toString(), I do not get the result I am looking for.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably are looking for an XML file to a string, if I am not mistaken.
If that is the case, then you can use any Java I/O API to do this.

Converting an XML Node to a string means, converting the "value" of an XML Node to a string. BTW, an XML Node means - an XML Element, or an XML attribute or just simply the text inside an XML file. The "value" each such node depends on what type of Node it is.

- m
reply
    Bookmark Topic Watch Topic
  • New Topic