1
<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

Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
Master
  • 97
  • 2
  • 6

2 Answers2

2

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

Community
  • 1
  • 1
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
0

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
  • 97
  • 2
  • 6