This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hello all. Could someone kindly post some code to show me how to parse the following example XML data (read in from a string?) <?xml version="1.0" ?> <FORMDATA> <BILLING> <INVOICENO>1111111</INVOICENO> <CUSTOMERNO>ABC123</CUSTOMERNO> </BILLING> </FORMDATA> I'm using the JAXP parser. The document seems to be parsing okay, as I can System.out.println doc.getDocumentElement() and see the entire XML stream. Here's the code I've got so far, which isn't much:
I'm after the value of the INVOICENO and CUSTOMERNO. Is there some sort of way to access the value of these elements by XML tag names? Thanks in advance for the help, Rick <><
Hei after parsing you can take the values by getting to the node you can take this by using the method NodeList nl = Document.getElementsByTagName("INVOICENO"); as shown above this gives all the elements with the said name. Node invoice= nl.item(0); \\this gives you the code the value '0' denotes the first element Node value = invoice.getFirstChild(); \\this gives the text node from where you can take the value String s = value.getNodeValue(); Hope this helps Cheers :-) Palanikumar ------------------ In the end everything is Right,If it's not then It's not the End
In the end everything is Right,If it's not then It's not the End
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.