Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Parser

 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai all,
Is there any need for separate XMLparser for jdk1.4.If it is available how to use the XML parser. How to set the class path and what are the methods to parse the XML document. What parser can we use(SAX, DOM etc.). My requirement is to send a XML request & retrive a XML response and parse it.
Thanks in advance.
Jithesh
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are asking for a book - or at least a long article - do a search for "java XML tutorial" on yahoo.
Bill
 
S. Sumukh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Afaik jdk1.4 wont come with built in xml parser.
download it(xereces) from apache..
U can use SAX for ur requirement...its very simple..
sumukh
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Is there any sample code available for XML Parsing. I want to read an XML file and convert in to records with no tags.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A word of background: A DOM (document object model) style parser reads your XML and generates a tree of objects. I find working with the tree more complex than I need for simple stuff like reading a configuration file, but it is very good if you want to modify the data and write it back to new XML or use some other advanced features.
A SAX style parser calls a "handler" object of your choice every time it finds something interesting in the XML, like the start of a tag, some characters, the end of the tag, etc. It is relatively easy to write your own handler to collect the characters SAX sends you into records as it goes along. Since SAX doesn't build a tree in memory, it can use less memory. But it can't rewrite the tree to a new XML file.
Here is some work I did with SAX parsing. Make it your second tutorial on SAX as it assumes you did well with your first.
http://www.surfscranton.com/architecture/ReusableSAXParsers.htm
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java 1.4 has XML support - look at the packages starting with javax.xml, org.w3c.dom and org.xml.sax
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic