如何獲取子xml值?XmlPullParser獲取所有子值
我的意思是:如果xml.getName() = Section
給我它的子值。我想我必須使用一個while循環,但我無法實現它!
或有可能獲得父母的價值?
<Top name="Top category">
<Section name="Sub category 1">
<Sub note="text" />
<Sub note="text" />
</Section>
<Section name="Sub category 2">
<Sub note="text" />
<Sub note="text" />
</Section>
</Top>
...
while (eventType != XmlPullParser.END_DOCUMENT) {
if ((eventType == XmlPullParser.START_TAG) &&(_xml.getName().equals("Section"))){
String _Section = _xml.getAttributeValue(null, "name");
// take its Sub note values
}
}
}
是有可能使用'getDepth()'。如果我使用'_xml.getDepth() - 1',我認爲它會給我父母的深度,所以有可能得到父深度的值? – metemet06 2013-05-11 21:48:54
Urrr ..你需要什麼深度? – dmon 2013-05-11 23:09:26
我想獲取父節點值,同時獲取子節點(如果可能的話)。 – metemet06 2013-05-12 07:01:15