File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How to get value of an xml node which contains another xml 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 "How to get value of an xml node which contains another xml" Watch "How to get value of an xml node which contains another xml" New topic
Author

How to get value of an xml node which contains another xml

sahidul karim
Greenhorn

Joined: Sep 19, 2006
Posts: 28
How can I get value of an XML node which is internally represents another XML.
My xml :-

<?xml version="1.0"?>
<Entity name = "RuleSetInfo">
<Column name="definition">
<RuleSet>
<Product comment="" id="PRODUCT_10" legislationbase="" producttype="RT1">
<Label highlightonfailure="true">
<RuleName>
<Text locale="en_US" value="Liability Overbilling"/>
</RuleName>
<SuccessText>
<Text locale="en_US" value="Product Succeeded"/>
</SuccessText>
</Product>
</RuleSet>
</Column>
</Entity>

I want to retrieve value inside the <Column> VALUE</Column> tag and I am using SAX parser.

VALUE:- represents another XML which is
<RuleSet>
<Product comment="" id="PRODUCT_10" legislationbase="" producttype="RT1">
<Label highlightonfailure="true">
<RuleName>
<Text locale="en_US" value="Liability Overbilling"/>
</RuleName>
<SuccessText>
<Text locale="en_US" value="Product Succeeded"/>
</SuccessText>
</Product>
</RuleSet>
How can I get this inner XML as VALUE of <Column> node?

Regards,
sahidul
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18879
    
    8

When you say you want to "get" the XML, exactly what do you mean by that? Do you want the XML rendered as text, or in some internal form, or what?
sahidul karim
Greenhorn

Joined: Sep 19, 2006
Posts: 28
I want to get that xml as a textual representation ( I need to store the vale as a string).
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12821
    
    5
Seems to me that all you need to do is start a new StringBuffer when you get the startElement event.
Collect what you need from the following events in the StringBuffer until you hit the endElement event and bingo.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get value of an xml node which contains another xml