Jdom parsing

hi iam new to java and jdom parsing.my imput is user passes the xml file and a string (string is not a tag in xml its a attribute value).i need to look for the string in the xml file and get all its child attributes .my xml looks like

<Trs>

<cetTra>

<xName>"jeff"</xName>

<child>pat</child>

<child>sush</childT>

<Delay>

<timeSec>60</timeSec>

<retry>1</retry>

</Delay>

</cetTra>

<cetTra>

<xName>"kumsa"</xName>

<child>sac</child>

<child>ed</child>

<Delay>

<timeSec>5</timeSec>

<retry>10</retry>

</Delay>

</cetTra>

</Trs>

my quesion is how to get only the the contents based on attribute .Input string will be jeff i need to get the contents only for jeff .my code looks like

List passedStringList = root.getChildren("Cetra");

Iterator i = passedStringList.iterator();

while (i.hasNext()){

Element serv= (Element) i.next();

out.print("\t" + serv.getChild("xName")

.getText());

o/p gets both jeff and kumsa

Thanks for the help

[1483 byte] By [kumsaa] at [2007-11-26 14:29:54]
# 1

XML file has an error at <child>sush</childT>. It should be </child>

Since jdom uses SAX structure, devise a recursive depth search function similar to listChildren() in http://www.cafeconleche.org/books/xmljava/chapters/ch14s08.html . It contains examples on jdom as well. Test whether current object returned by iterator is an instance of Element. and content is "jeff".

if ( child.getContent().equalsIgnoreCase("\"jeff\"") )

Then invoke listChildren() once again with current Element object as start point. Manipulate print statements to suit your need.

java_a at 2007-7-8 2:24:25 > top of Java-index,Java Essentials,New To Java...
# 2
hi thanks for the help i still get the chilldrens for both.Is there a diffrent approch i can implementthx again
kumsaaa at 2007-7-8 2:24:25 > top of Java-index,Java Essentials,New To Java...
# 3
For your requirements I would suggest DOM Parsing instead of jdom.
java_a at 2007-7-8 2:24:25 > top of Java-index,Java Essentials,New To Java...
# 4
Did that help ?
java_a at 2007-7-8 2:24:25 > top of Java-index,Java Essentials,New To Java...