Sunday, March 17, 2013

Re: XMLParser Problems

First, it appears that your XML is invalid ... your last child element has a beginning tag of "ACCT005" and an ending tag of "vlst".  Assuming that this isn't your only problem, I think you are just not getting the child nodes of the "item" element, but instead you are getting the child nodes of the document (which would be the "item" element node).  This is how I'd fulfill your requirements:

  final Document doc = XMLParser.parse(item);
  final Element itemElement = (Element)doc.getElementsByTagName("item").item(0);
  Node node = itemElement.getFirstChild();
  while (node != null) {
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      // node is an account element
    }
    node = node.getNextSibling();
  }
Note that not all child nodes will necessarily be Element nodes ... hence the check for NodeType == Node.ELEMENT_NODE.

Andy

On Thursday, March 14, 2013 6:02:13 AM UTC-7, skippy wrote:
I am trying to load this xml file into a hashmap or list using XMLParser.  What ever I try, I keep getting a node list of 1 with all the nodes in it.
 
Here is an example of the xml file:
...

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate