Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can an XML Node be converted to a String

 
Joya Patterson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic