Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] Problems by parsing XML with JDOM

ajoecker

2006-04-11


Hello,
I like to parse a XML document with JDOM. I get the root element without problems, but no child elements. I hope someone can tell me what I do wrong.
Thanks,Anika
Here is my code:
SAXBuilder builder = new SAXBuilder(); Document doc = null; ????????????????doc = builder.build(new StringReader(xml));Element root = doc.getRootElement();System.out.println(root.getName());Element header = root.getChild("Header"); Element program = header.getChild("program"); System.out.println(program.getAttributeValue("name")); <- Here I get a NullPointerExeption, because the variable program is empty

And here is my XML code:
<?xml version="1.0"?><EBIApplicationResult xmlns="http://www.ebi.ac.uk/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ebi.ac.uk/schema/ApplicationResult.xsd"><Header>????????<program name="WU-blastp" version="2.0MP-WashU [01-Jan-2006]" citation="PMID:12824421"/>????????<parameters>????????????????<sequences total="1">????????????????????????<sequence number="1" name="Sequence" type="p" length="39"/>????????????????</sequences>????????????????<databases total="1" sequences="2966745" letters="967946558">????????????????????????<database number="1" name="uniprot" type="p" created="2006-04-04T00:57:47+01:00"/>????????????????</databases>????????????????<scores>100</scores>????????????????<alignments>50</alignments>????????????????<matrix>BLOSUM62</matrix>????????????????<expectationUpper>1</expectationUpper>????????????????<statistics>sump</statistics>????????</parameters>????????<timeInfo start="2006-04-11T11:15:36+01:00"!
end="2006-04-11T11:15:41+01:00" search="PT05S"/></Header></EBIApplicationResult>
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.