I got a slight problem. I have been trying to read in XML in Java using the javax.xml.parsers.DocumentBuilder and javax.xml.parsers.SAXParser classes but to no success . I new to using XML with java.
What I need is to parse XML and be to retrieve the values or each tag.
Below is a sample of the XML i need to pass:
<?xml version="1.0" encoding="utf-8" ?>
<ns:SISubscriberProfile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="http://www.openuri.org/">
<ns:Message>GET_CUSTOMER : SUCCESS</ns:Message>
If you take the line <ns:FirstName>Shaun</ns:FirstName>. I need to be able to pass a string (tag name, example "ns:FirstName") to a method and it should return the value of that tag as a string ("Shaun"). All the values i need to read are Strings.
I use the basic code in the attachment (rename file to *.java).
I can read the tagname but i can't get the value . What am i doing wrong? If possible could someone help me out by showing me the right code to read the value between the XML tag.