我一直在尝试使用 XmlResourceParser,但我觉得它不是适合这项工作的工具。我有一组包含子项目的项目,我想提取一个特定项目,例如此列表中的第二个项目:
<story>
<id>1</id>
<name>The First Room</name>
<description>You aren't sure how you ended up here, but there is nothing in this room of interest. You should probably escape.</description>
<direction>
<name>North</name>
<id>2</id>
</direction>
<direction>
<name>East</name>
<id>3</id>
</direction>
</story>
<story>
<id>2</id>
<name>Moldy Room</name>
<description>This room is filled with mold. It would be hazardous to your heath to stick around here.</description>
<direction>
<name>South</name>
<id>1</id>
</direction>
<direction>
<name>West</name>
<id>4</id>
</direction>
</story>
简而言之,我希望能够通过“id”数字拉动它们,而不必设置我自己的对象。如果可能的话。