This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

XML Parser  RSS feed

 
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
 
Author and all-around good cowpoke
Rancher
Posts: 13078
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
 
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.
 
(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: 13078
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!