Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read an XML file in java?

 
gani bhasky
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an XML file. I need to read this file and in some line of code in XML (say 4)there is a file "file1.some". I need to change this to "file2.some". How to do this in java?
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading and writing is just like I/O. The trick part is to read in the values from a XML file. There are many ways to do this. You can use Xerces, JDOM, JAXP.
 
gani bhasky
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank U for your reply. I just downloaded xerces.jar file, can you just tell me what to do next. From Java have to read a value from an XML file and write some other value. Can you please explain the steps.
with thanks,
gani.
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gani,
You should read the sample code: http://xml.apache.org/xerces-j/samples.html and the FAQ to see how to use the parser: http://xml.apache.org/xerces-j/faqs.html. The documentation for the Xerces parser are pretty well written and up-to-date.
-Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic