[jdom-interest] Accessing Child Elements

Rodney Sonderegger rodney.sonderegger at incaparc.ch
Tue Sep 5 11:20:07 PDT 2000


we're testing JDOM in our application and I found some strange things,
which I can't explain.
I'm using the SAXBuilder to read the Streamdata passed by the Database
  <?xml version="1.0" encoding="utf-8" ?>
  <xql:query>Profile[ProviderKey="0011" and
 <ino:message ino:returnvalue="0">
  <ino:messageline>XQL Request processing</ino:messageline>
 <Profile ino:id="2">
 <ino:cursor ino:count="1">
  <ino:first ino:href="?_XQL(1,16)=Profile[ProviderKey="0011" and
Application="eRetail"]" />
 <ino:message ino:returnvalue="0">
  <ino:messageline>XQL Request processed</ino:messageline>

The Parser works fine and parses the document without errors.
I'm interested in the <Profile> Element and try to get it with:

      Element root = aDoc.getRootElement();
      Element xmlProfile = root.getChild("result").getChild("Profile");

I get an NULL Pointerexception trying to do that.
when I  run an Iterator:

    Iterator anIt = root.getChildren().iterator();
      while (anIt.hasNext()){
        Element aElem = (Element) anIt.next();
        if (aElem.getName().equals("result")){
          xmlProfile = aElem;

then I can access the subelements of <result> does anybody know why this

is the case??

Thanx & Regards

More information about the jdom-interest mailing list