Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read xml file like below

 
balaji pothula
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version="1.0" encoding="utf-8"?>
<tv>
<programme start="20120608145500+0530" stop="20120608150000 +0530" channel="0980.DD1.in">
<title>KIRAN</title>
<date>20120608</date>
<category>DOCUMENTARY</category>
</programme>
<programme start="20120608150000 +0530" stop="20120608153000 +0530" channel="0980.DD1.in">
<title>KASHMAKASH ZINDAGI KI</title>
<date>20120608</date>
<category>TV SHOW</category>
</programme>
</tv>


In the above xml file i want to read start corresponding value 20120608145500 +0530, stop corresponding value 20120608150000 +0530 and channel corresponding value 0980.DD1.in
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are any number of XML APIs you could use: SAX, DOM, XPath, dom4j, XOM, JDOM, StAX... If you haven't used any API, try out a few to see which you like best.

I probably wouldn't start with SAX, though, it requires more code to be written than most of the other APIs. XPath might be a good fit if you want to extract a few specific, well-defined values out of a document.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic