Results 1 to 4 of 4

Thread: Parsing XML

  1. #1
    virvalid is offline Member
    Join Date
    Aug 2009
    Rep Power

    Default Parsing XML

    Hi to all, this is my first post. I need some help in parsing XML. I am using SAX, and i can parse the XML.

    The problem is which data structure should i use to store the values e.x:

    1st Author
    <BOOK_SECTION="1" IDAUTH="0000011111" NOSTORES="4" SALES="YES">
    <PRICE ="188" SHIPPINGCOST="121" />

    <DETAIL_BOOK SEARCHNO="1" IDSEARCHNO="1111111111111111" STORE="A" />
    <DETAIL_BOOK SEARCHNO="2" IDSEARCHNO="1111111111111112" STORE="B" />
    <DETAIL_BOOK SEARCHNO="3" IDSEARCHNO="1111111111111113" STORE="B" />
    <DETAIL_BOOK SEARCHNO="4" IDSEARCHNO="1111111111111114" STORE="D" />

    2nd Author
    <BOOK_SECTION="2" IDAUTH="0000011111" NOSTORES="3" SALES="YES">
    <PRICE ="182" SHIPPINGCOST="121" />

    <DETAIL_BOOK SEARCHNO="1" IDSEARCHNO="1111111111111121" STORE="AA" />
    <DETAIL_BOOK SEARCHNO="2" IDSEARCHNO="1111111111111123" STORE="BB" />
    <DETAIL_BOOK SEARCHNO="3" IDSEARCHNO="1111111111111124" STORE="DD" />

    OK i want to use a hashmap (key/value pairs) .e.x > the key will be
    <BOOK_SECTION> and values for each <BOOK_SECTION> will be

    My question is can i ? Can i have something like

    HashMap hMapXML = new HashMap();

    hMapXML.put("1",ARRAYLIST()); or

    hMapXML.put("1",ARRAY[]); ?

    Many Thanks :)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    My guess is that HashMap would be too simple for this and would only allow one DETAIL_BOOK for each BOOK_SELECTION. Better perhaps is to create a class to hold the information. It can perhaps have a field for the BOOK_SELECTION, a field for price and other bits of info if desired and an ArrayList for the DETAIL_BOOK data. Then objects of this class could be placed into a HashMap if desired.

  3. #3
    virvalid is offline Member
    Join Date
    Aug 2009
    Rep Power

    Default Thanks

    Hi, thanks for your reply, is it possible to have an example how to implement it, a link / a post something :)

    Many thanks.

  4. #4
    virvalid is offline Member
    Join Date
    Aug 2009
    Rep Power


    Hey thanks again, i think i have figured it out :) ,

    Many thanks

Similar Threads

  1. Parsing
    By Matt Sakko in forum New To Java
    Replies: 14
    Last Post: 03-21-2009, 05:49 PM
  2. Xml Parsing
    By Nomad in forum XML
    Replies: 12
    Last Post: 02-22-2009, 12:19 PM
  3. xml parsing help
    By tankhardrive in forum XML
    Replies: 2
    Last Post: 02-12-2009, 12:45 AM
  4. xml parsing
    By gaurav65176 in forum XML
    Replies: 5
    Last Post: 11-12-2008, 12:07 PM
  5. Parsing URL
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts