我在 android 中使用 dom xml 解析器。在我的源代码 xml 中包含父子名称相同的名称。
解析xml数据时如何区分父标签和子标签?
这是我的示例 xml。
<alerts>
<alert>
<code>QWEOS</code>
<alert>this is alert1</alert>
<description>this is description</description>
</alert>
<alert>
<code>SDFHP</code>
<alert>this is alert2</alert>
<description>this is description</description>
</alert>
</alerts>
最佳答案
您可以创建文档 doc。
NodeList nodes = doc.getElementsByTagName("parentnode");
Element e = (Element) nodes.item(i);
flag =XMLfunctions.getValue(e,"childnode");
关于android - dom解析时如何区分父子标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13245874/