views:

90

answers:

2
<autos>
    <cars>
      <car>
        <type>Toyota</type>
        <year>1999</year>
      </car>
      <car>
        <type>Honda</type>
        <year>2010</year>
      </car>
    </cars>
</autos>

i want to extract car object from the above code whats the possible way. can i have the sample code or any example

thanks in advance

A: 

Blockquote

Here is the sample xml file

<cars>

  <car>

    <type>Toyota</type>

    <year>1990</year>

  </car>

  <car>

    <type>Honda</type>

    <year>1998</year>
  </car>

Master
+2  A: 

You can use SAX parser here. Check element name, if its car, create instance of car object if its type or year, take characters and set properties of car object... etc

See similar approach: SO - BlackBerry/J2ME - SAX parse collection of objects with attributes

Max Gontar
We're also using SAX, works well
Tamar