Results 1 to 4 of 4
Thread: Parsing XML
- 08-07-2009, 02:06 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 3
- Rep Power
- 0
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" />
</BOOK_SECTION>
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" />
</BOOK_SECTION>
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
<DETAIL_BOOK>.
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 :)
-
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.
- 08-10-2009, 07:46 AM #3
Member
- Join Date
- Aug 2009
- Posts
- 3
- Rep Power
- 0
Thanks
Hi, thanks for your reply, is it possible to have an example how to implement it, a link / a post something :)
Many thanks.
- 08-10-2009, 12:40 PM #4
Member
- Join Date
- Aug 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Parsing
By Matt Sakko in forum New To JavaReplies: 14Last Post: 03-21-2009, 04:49 PM -
Xml Parsing
By Nomad in forum XMLReplies: 12Last Post: 02-22-2009, 11:19 AM -
xml parsing help
By tankhardrive in forum XMLReplies: 2Last Post: 02-11-2009, 11:45 PM -
xml parsing
By gaurav65176 in forum XMLReplies: 5Last Post: 11-12-2008, 11:07 AM -
Parsing URL
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:16 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks