This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi, Hopefully this is a really easy question for someone - I am looking for the easiest way to extract the values out of this xml string: I am limited to using Java 1.3. The tag names will always be the same. Is there an existing Java class/api, which will do this - or do I have to just string parse this thing. <?xml version="1.0" encoding="ISO-8859-1" ?> <OUTBOUND> <NAME>Joe Blow</NAME> <FILENAME>c:\\tmp\\SampleFile.txt</FILENAME> <ID>1234</ID> <SUM>23123</SUM> </OUTBOUND> To be clear I need to extract, Joe Blow, c:\\tmp\\SampleFile.txt, etc. from this string. Many Thanks!
I am SAX/DOM challenged, so I can't give you a Java program to do what you are looking for. Look for any SAX/DOM examples and you case use the API messages to do what you want. Thanks. - madhav.........currently good at XSLT!!!
You can get the "OUTBOUND" element with Document#getDocumentElement(). Then you can access "NAME", "FILENAME", "ID", and "SUM" with Node#getChildNodes(). The value of each element can be obtained using Node#getNodeValue().
Thanks for the replies. Could you be more specific? What class is this from: You can get the "OUTBOUND" element with Document#getDocumentElement(). Then you can access "NAME", "FILENAME", "ID", and "SUM" with Node#getChildNodes(). The value of each element can be obtained using Node#getNodeValue(). Any code samples? Also, from the examples I have seen is there anyway I can use the dom or sax parsers or something else without having an actual xmlFile - my program has an xml string that I am reading off a queue, that I need to parse. Many Thanks!
Joined: Jan 23, 2002
What class is this from:
Classes org.w3c.dom.Document and org.w3c.dom.Node.