This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
Here's an xml question. Suppose I have an xml structure called defined as follows:
<orders> <order> <partNum>12345778A</partNum> <description>widget controller</description> <quantity>2</quantity </order> <order> <partNum>67789A2C</partNum> <description>widget adapter</description> <quantity>3</quantity </order> . another order . another order </orders>
In my xml file, I have several orders. Suppose I'd like to iterate through and see all the nodes in each order. By doing
NodeList orders = root.getElementsByTagName(�order�); I�m able to iterate through and print each node name, but when I try to print the node value, I get null. Should I cast to an Element instead of node? As you can see, there no attributes, and I did this intentionally to learn how to pull data out of a Node.
That will work well for your particular question. But note that getTextContent() does exactly what it says, and that might not be what you expect in the case of mixed content elements. Try it on the <orders> element of your original post, for example, and see what it produces.