Parsing XML in Java

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Parsing XML in Java

Threaded View

  1. #1
    Join Date
    Apr 2004
    Cape Town, SA

    Exclamation Parsing XML in Java

    Hello Experts

    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="" xmlns:xsi="" xmlns:ns="">
    <ns:Message>GET_CUSTOMER : SUCCESS</ns:Message>
    <ns:IsLive xsi:type="xsd:boolean">true</ns:IsLive>

    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.

    Thank you.
    Attached Files Attached Files
    _/\/ \/\_

Similar Threads

  1. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  2. Replies: 1
    Last Post: 05-02-2002, 07:57 AM
  3. Try XML Junction
    By Tim in forum xml.announcements
    Replies: 0
    Last Post: 10-11-2001, 04:00 PM
  4. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 10:53 AM
  5. Replies: 1
    Last Post: 03-20-2001, 02:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center