Android 从XML标记中提取和加载图像
我正在使用XmlPullParser解析xml文件,我成功地加载了所有其他标记,但我想知道如何从这个标记和描述行中提取图像,如下所示 形象 这条线也是Android 从XML标记中提取和加载图像,android,xmlpullparser,Android,Xmlpullparser,我正在使用XmlPullParser解析xml文件,我成功地加载了所有其他标记,但我想知道如何从这个标记和描述行中提取图像,如下所示 形象 这条线也是 <BR>Christian Eriksen has reportedly made the decision to leave Tottenham Hotspur in the New Year after declining to sign a new contract.</p> 谢谢好的, 首先像完成一样提取标签
<BR>Christian Eriksen has reportedly made the decision to leave Tottenham
Hotspur in the New Year after declining to sign a new contract.</p>
谢谢好的,
首先像完成一样提取标签
然后,您可以从url或使用毕加索的文件加载图像。检查
检查此链接以处理子节点
您可以使用毕加索从url或文件加载图像。检查一下。但是如果你不介意的话,我主要想知道如何从标记中获取它,因为我使用了getAttributeValue(null,“img”);它不起作用谢谢你建议我这样做,但在我使用XmlPullParser的情况下,是否有使用XmlPullParser获取标记属性值的示例谢谢。既然根标记中有子标记,我是否应该再次调用(xpp.getName().equals(“childtag”),然后将该值分配给我的视图
<BR>Christian Eriksen has reportedly made the decision to leave Tottenham
Hotspur in the New Year after declining to sign a new contract.</p>
<description><![CDATA[<p><A
HREF='https://www.eyefootball.com/news/42653/Christian-Eriksen-Tottenham-
Hotspur-transfer-decision.html'><img border='0'
src='https://www.eyefootball.com/imghold/thumbChristianEriksen_2019.jpg'></A>
<BR>Christian Eriksen has reportedly made the decision to leave Tottenham
Hotspur in the New Year after declining to sign a new contract.</p>]]> </description>
try {
URL url = new URL("https://www.eyefootball.com/football_news.xml");
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(GetInputStream(url), "utf-8");
boolean insideItem = false;
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (xpp.getName().equalsIgnoreCase("item")) {
insideItem = true;
} else if (xpp.getName().equalsIgnoreCase("title")) {
if (insideItem) {
rssModel.setTitle(xpp.nextText());
}
} else if (xpp.getName().equalsIgnoreCase("pubDate")) {
if (insideItem) {
rssModel.setPublished(xpp.nextText());
}
} else if (xpp.getName().equalsIgnoreCase("guid")) {
if (insideItem) {
rssModel.setLinks(xpp.nextText());
}
} else if (xpp.getName().equalsIgnoreCase("description")) {
/// i want to get the child tags ( img and last line ) from
/// descritpion tag
}
} else if (eventType == XmlPullParser.END_TAG && xpp.getName().equalsIgnoreCase("item")) {
insideItem = false;
list.add(rssModel);
}
eventType = xpp.next();
}
} catch (MalformedURLException e) {
exception = e;
} catch (XmlPullParserException e) {
exception = e;
} catch (IOException e) {
exception = e;
}
}