I'm trying to parse an XML file in Java using the XOM library. Where i'm running into an issue is when i hit nested elements. So in XOM you start with a root node, and i am able to parse the attributes out of that root node, and the three child nodes. This isnt the XML itself but i'll lay out an example.

<root id="" name="" >
    <child1   att="" />
    <child2   att="" />
    <child3   att="" />
    <child4   att="" > -->Here is where i can't seem to parse <child4nested2> yata yata </child4nested2> 
    <child4nested2> yata yata </child4nested2> <--Up to here
    </child4>
</root>

So i can access all the root attributes, and i can access all the child attributes by doing Elements enteries = root.getChildElements(); It even parses this <child4 att="" > and gets the att out, but i cannot figure out how to parse the child of a child of the root element, i though it would be something like
Elements element2 = child4.getChildElements(); but that returns a null pointer.
Any help would be great
thanks

You need to post the entire self-contained code which can be used to re-produce the issue. I really see no reason why nested elements wouldn't work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.