• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

parsing the XML tags values having the same name

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i have the XML file like this,
<CoDetails>
<SupportingDocument>
<documentID>LC</documentID>
<fileType>COO3333.jpeg</fileType>
<fileSize>123</fileSize>
</SupportingDocument>
<SupportingDocument>
<documentID>RE</documentID>
<fileType>COO2222.jpeg</fileType>
<fileSize>100</fileSize>
</SupportingDocument>
<SupportingDocument>
<documentID>LP</documentID>
<fileType>COO1111.jpeg</fileType>
<fileSize>200</fileSize>
</SupportingDocument>
<SupportingDocument>
<documentID>BL</documentID>
<fileType>COO34444.jpeg</fileType>
<fileSize>300</fileSize>
</SupportingDocument>
</CoDetails>
can u please give me the java codes to retreive separately the values in each of the "supportingDocument" tag in a vector containing "documentID", "fileType" and "FileSize" values
thanks
sathish :roll:
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgive me if i'm wrong.
Instead asking the whole java code.. why don't u try something and comeup with partly working code and then ask for help ?.. By this way u will learn more.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a piece of code that prints the values of the three tags.
The Vector part I left for you ;-)
You need Java 1.4 to run this code.
If you find a way to achieve this using an Xpath class, please let me know.
Cheers,
Dan
 
sathish kannan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your effort. it works good for me after i made some alteration ....
once again thanks a lot
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sathish,
I have here an improved version of this code that uses the Document getElementByTagName method.
It needs some cleaning

Cheers,
Dan
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic