开发者

BlackBerry - Extract data from 3rd nesting level of xml

<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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜