Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何解析特定的XML标记_Java_Android_Xml_Xml Parsing - Fatal编程技术网

Java 如何解析特定的XML标记

Java 如何解析特定的XML标记,java,android,xml,xml-parsing,Java,Android,Xml,Xml Parsing,目前,我一直在解析简单的标记,但我不知道如何处理更复杂和重复的标记 我一直在做的代码示例: while (xpp.getEventType()!=XmlPullParser.END_DOCUMENT) { if (xpp.getEventType()==XmlPullParser.START_TAG) { if (xpp.getName().equalsIgnoreCase("description")) { weatherDetails.setW

目前,我一直在解析简单的标记,但我不知道如何处理更复杂和重复的标记

我一直在做的代码示例:

while (xpp.getEventType()!=XmlPullParser.END_DOCUMENT) {
    if (xpp.getEventType()==XmlPullParser.START_TAG) {
        if (xpp.getName().equalsIgnoreCase("description")) {
            weatherDetails.setWeatherLocation(xpp.nextText());
            weather_userlocation.setText(weatherDetails.getWeatherLocation());
        }
    }
所以我可以挑出标签,因为他们只有一个。。。但如果存在多个:

-<weather time-layout="k-p12h-n14-1">
    <name>Weather Type, Coverage, Intensity</name>
       <weather-conditions weather-summary="Mostly Cloudy"/>
       <weather-conditions weather-summary="Rainy"/>
</weather>
-
天气类型、覆盖范围、强度
我想选择第一个天气条件,并得到文本“大部分多云”。 如何将重复的特定标签单列出来

谢谢c:

你可以看看。您不必编写自己的解析器