Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading child tags as separate xml blocks

 
rakesh kumar nampally
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a sample xml:



now i have to read each <ROW> block from xml and send that as string to a method.

I'm using DOM parser, i tried it but unable to read each <ROW> as a separate block.

Kindly suggest to accomplish the above task.

Thanks,
Rakesh.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read each <ROW> as a separate block.


Exactly what output would you like to see in the output String?

If you want a String containing both the XML tags and the text content, you will have to create it with DOM methods because the DOM model keeps the tag names and text content separate.

I always recommend study of the org.w3c.dom.Node JavaDocs. There is a lovely table there that summarizes how DOM keeps things like the names and content of tags.

Bill
 
rakesh kumar nampally
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for quick reply!!!

I got it i have used TransformerFactory to convert an xml (DOM) node into string representation.

sample code:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic