开发者

BlackBerry - Extract data from 3rd nesting level of xml

开发者 https://www.devze.com 2022-12-23 23:09 出处:网络
<autos> <cars> <car> <type>Toyota</type> <year>1999</year> </car>
<autos>
    <cars>
      <car>
        <type>Toyota</type>
        <year>1999</year>
      </car>
      <car>
        <type>Honda</type>
        <year>2010</year>
      </car>
    </cars>
</autos>
开发者_JAVA百科

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


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


Blockquote

Here is the sample xml file

<cars>

  <car>

    <type>Toyota</type>

    <year>1990</year>

  </car>

  <car>

    <type>Honda</type>

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号