File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes parsing the XML tags values having the same name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "parsing the XML tags values having the same name" Watch "parsing the XML tags values having the same name" New topic
Author

parsing the XML tags values having the same name

sathish kannan
Greenhorn

Joined: Jul 11, 2002
Posts: 29
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

Joined: Jul 13, 2001
Posts: 3150
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

Joined: Jul 09, 2001
Posts: 1178
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


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
sathish kannan
Greenhorn

Joined: Jul 11, 2002
Posts: 29
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

Joined: Jul 09, 2001
Posts: 1178
Sathish,
I have here an improved version of this code that uses the Document getElementByTagName method.
It needs some cleaning

Cheers,
Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: parsing the XML tags values having the same name