File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Parsing XML string using Java Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing XML string using Java Program" Watch "Parsing XML string using Java Program" New topic
Author

Parsing XML string using Java Program

Raghuraman Muthuswamy
Ranch Hand

Joined: Mar 18, 2003
Posts: 73
Dear All,
I am trying to parse a XML file without using SAX or DOM. I would like to develop a simple parser. If you provide me some tutorials about this it will be very useful. The main thing is the XML file should be parsed by Java Application Program.

Thanks in advance,

regards,
Raghu
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Thinking out loud here, parsing XML file without SAX and DOM -

To me this means, read the XML file as a text file and manipulate what various characters mean. Say if you encounter a '<' symbol, possible indication of a start or end element. If the '<' char is immediately followed by a '/' char, it indicates a end element.

Unfortunately I don't have any links handy to that detail, but any text parsing java code could be used as a tutorial.
I would love to see other thoughts on this.
Thanks.

- m


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Raghuraman Muthuswamy
Ranch Hand

Joined: Mar 18, 2003
Posts: 73
Dear Madhav,
Even Iam thinking the same way. Have to check for each < and > tags and put the tag value in a string. if you provide me with some text parsing tutorials it will be very helpful.

Thanks in advance,

Regards
Raghu
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Remember that XML has requirements for nesting elements to make "well formed" XML so parsing will resemble processing algebraic notation.
Since XML parsers have been part of the standard Java release since Java 1.4 , any Application Program can parse XML.
A number of open source simple XML parsers have been developed - for example the kXML project.
You might find inspiration there.
Bill
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Raghuraman Muthuswamy:
if you provide me with some text parsing tutorials it will be very helpful.



I remember William Brogden mentioned about using StringTokenzier or some related API for a question related to reading a csv like text file. Cant get that particular post.
I guess u r interested in developing ur own parser, i would suggest you to looking into the source of kXML,Xerces, Crimson and see how they have done it ??
Cheers
Balaji


Spritle Software Blogs
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Parsing XML string using Java Program
 
Similar Threads
Java-Generic Interface
xml validation agains xsd
Convert XSD to XML
Sorting XML nodes?
editing data in xml file