aspose file tools*
The moose likes XML and Related Technologies and the fly likes Retrieve inner XML & convert into String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Retrieve inner XML & convert into String" Watch "Retrieve inner XML & convert into String" New topic
Author

Retrieve inner XML & convert into String

Ash Shri
Greenhorn

Joined: Aug 07, 2013
Posts: 1
I am looking to get the inner xml as String type from the XML file.

for e.g.
<xml version = "1.0">
<Root>
<Child1>abc</Child1>
<Child2>xyz</Child2>
<ChildN>bcd</ChildN>
</Root>

I am looking to get the inner xml of <Root> node as String like -
String s = "<Child1>abc</Child1>
<Child2>xyz</Child2>
<ChildN>bcd</ChildN>"

Is it possible to do it through JAX-B or should I get it through some XML parser. If the XML is a large file with around 300 <ChildN> nodes, would it impact the performance in case of parsing it.

Could you please help with the code snippet, if possible.

Thanks in advance.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
If all you want is the text between the <root> and </root> lines that is not an XML problem at all but a text file reading one.

Open the file with a reader, read line by line, start writing content to a string buffer when you pass the opening Root tag and repeat til you hit the closing tag.

Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieve inner XML & convert into String
 
Similar Threads
Find Level of Element in XML
Problem in creating XML using DOM
Can an XML Node be converted to a String
Create New XML Document using XPATH
Deleting the children from node - xml