• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

parsing the XML tags values having the same name

 
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:
 
author and deputy
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.
 
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
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!