How Can I parse a xml file ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anilkunar
    New Member
    • Aug 2008
    • 1

    How Can I parse a xml file ?

    Suppose I have a xml file named person.xml i.e.

    <person>
    <name>
    <firstname>
    Anil
    </firstname>
    <lastname>
    Nayak
    </lastname>
    </name>
    <name>
    <firstname>
    Praveen
    </firstname>
    <lastname>
    Nayak
    </lastname>
    </name>
    <address>
    hebbagodi
    </address>
    <street lane="MaruthiNa gar">
    12thcross
    </street>
    </person>
    </person>

    Tell me How can I parse all the element,attribu te and root element
    by using dom and sax parser both?
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by anilkunar
    Tell me How can I parse all the element,attribu te and root element
    by using dom and sax parser both?
    Search on Google: Parsing with DOM and Parsing with SAX. You'll find loads of tutorials and examples there.

    Greetings,
    Nepomuk

    Comment

    • blazedaces
      Contributor
      • May 2007
      • 284

      #3
      What have you done to solve this problem on your own? We're not here to do your work for you.

      Why use both? One is much more suitable than the other for specific situations.

      SAX parses through one element at a time. It is often much more useful when you want to parse very large files or not even finish the entire file. DOM creates a sort of hierarchy and stores it, so it is more useful in smaller files (like this one I guess).

      Good luck,
      -blazed

      Comment

      Working...