Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parsing the XML tags values having the same name

 
sathish kannan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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:
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • 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.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic