• 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Efficent way to parse XML Data  RSS feed

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am not too familiar with DOM API. Currently I have the following XML File,






And My Java Code to parse it will be:






My Code seems not too efficient as it's kind of hard code.
My ideal wish will be getting values dynamically, please teach me how


Myriads of Thanks


Transistor

[ January 11, 2008: Message edited by: YuenLian Wu ]
[ January 11, 2008: Message edited by: YuenLian Wu ]
 
Rancher
Posts: 42973
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might check out XPath. It allows you to retrieve specific nodes from a DOM tree without having to write the code to work your way through the tree. Plus, you can keep the XPath expression as a string in a config file, thus making the code a bit more independent of the XML structure.
 
author
Sheriff
Posts: 8981
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
intermediate bound...
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We would suggest you to look at an open source API - JDOM. JDOM is an XML parsing API exclusively for Java. It uses DOM API to parse XML files and make the parsed data availabe as Java objects. It can be downloaded from jdom.org. Most the questions are answered in their tutorial, but if you need any help, let us know.


Hope this helps!

Sincerly,
Your friends at www.javaadvice.com
www.javaadvice.com - The place where your Java questions are answered directly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!