안드로이드에서 Pull Parser를 사용하여 image2 및 image3 값을 가져 오려고합니다.Android 용 Pull Parser에서 일치하는 태그가있는 XML 콘텐츠를 얻는 방법은 무엇입니까?
<item>
<title>Title Goes Here!</title>
<picture><![CDATA[http://blahblah.image.jpg]]></picture>
<picture><![CDATA[http://blahblah.image2.jpg]]></picture>
<picture><![CDATA[http://blahblah.image3.jpg]]></picture>
</item>
...
case XmlPullParser.END_TAG
if (tagname.equalsIgnoreCase("item")
_feed.addItem(_item);
} else if (tagname.equalsIgnoreCase("title")) {
_item.setTitle(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage2(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage3(theString)
}
break;
...
내가 분석하고 첫 번째 이미지를로드하지만, 나는 다음 단계는 다른 이미지를 얻기 위해 무엇인지 할 수 있습니까? 도와 주셔서 감사합니다. 만난 태그 picture
경우
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage2(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage3(theString)
}
두 번째와 세 번째
else if
조건 테스트를 다음 코드가 실행되지 않습니다
, 제어 흐름은 처음에 종료됩니다 :
는이 목록에서 이미지 URL 년대를 저장하는 더 이해하지 않는 것 :
당신은 당신이 원하는 것을 달성하기 위해 다음을 수행 할 수 있습니다? 어쨌든 현재 코드의 경우 tagname.equalsIgnoreCase ("picture") 조건 (첫 번째'if'가 결코 실행되지 않을 것이므로)이 하나만 있어야하며 처리 한 URL의 수를 계속 유지해야합니다. 그러면 해당 setter를 호출하는 데 사용할 수 있습니다. –
+1. 목록 변수를 유지하고 실행 URL을 "picture"태그와 함께 추가하십시오. – dmon