GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Reading child tags as separate xml blocks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Reading child tags as separate xml blocks" Watch "Reading child tags as separate xml blocks" New topic
Author

Reading child tags as separate xml blocks

rakesh kumar nampally
Ranch Hand

Joined: Feb 03, 2007
Posts: 46
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.


thanks & regards, Rakesh
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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

Joined: Feb 03, 2007
Posts: 46
Thank You for quick reply!!!

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

sample code:

 
GeeCON Prague 2014
 
subject: Reading child tags as separate xml blocks