Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I get the grandchildren of the root in JDOM?

843834Aug 26 2001 — edited Aug 27 2001
Dear All,

This is my XML document:

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="style.css"?>
<DisruptionsInfo>
<Title>Disruptions on the London Underground</Title>

<noService>
<between>
<description>The are no service between</description>
<station>BAKER STREET</station>
<description>and</description>
<station>EUSTON SQUARE</station>
<description>on the</description>
<line>METROPOLITAN LINE</line>
</between>
</noService>

<description>The following station(s) are closed due to engineering works:</description>
<closed>
<station> Green Park </station>
<station> Maida Vale </station>
</closed>
<description>The following line(s) are closed due to flooding</description>
<DelaysLine>
<line>Jubilee line</line>
</DelaysLine>
</DisruptionsInfo>


I am interested in the the tags within the<between></between> tags which is within the <noService> tag.

Without the <between></between> tag I can get the content of the <station>tag using the following code.

PrintStream out = System.out;
try
{
SAXBuilder b = newSAXBuilder();
Document doc =b.build(filename);
//getting the root element
root = doc.getRootElement();
// getting a list of children and its size

// Get a List of all direct children as Element objects
allChildren = root.getChildren();

//noService
stations = root.getChildren("noService");
station = (Element) Stations.get(0);
stationNames = station.getChildren("station");

}


but since I have included the <between></between>tags, HOW can I make the program do the samething as before... ie. I want to get the content of <station>?

I just want the the program to be able to look at the content of <station> for each <between></between> section if there is one or more <between></between>

I will be grateful of your help
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2001
Added on Aug 26 2001
4 comments
355 views