I would like to process an element-based XML document that looks like this
as opposed to a attribute-based document that looks like this:
but I can't figure out how to extract the value associated with an element. I think that understand how to extract the value associated with an attribute based upon looking at some of the other posts in this forum. This is the first time I have worked with processing XML in Java. Before I actually get started, I'd like to get your opinion on the pros and cons on the formats of the messages above. Can someone point me towards the code for extracting the value from an element? This is the code that I have so far for reading the file:
Thank you for your advice and assistance! Robin [ April 24, 2004: Message edited by: Robin Clark ]
See what happens, the text under the ELEMENT node is not the text directly belonging to the Element node, instead element node has a Text Node under it which contains the value. So u need to use Element lText = msg.getFirstChild(); // TO get the text Node String lValue = lTest.getNodeValue(); // to get the value of the Text Node.