• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parsing XML string using Java Program

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Raghuraman Muthuswamy
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
reply
    Bookmark Topic Watch Topic
  • New Topic