如何可以解析在Android这个XML文件,以获得大的图像XML解析在Android的
<image size="small">http://userserve-ak.last.fm/serve/34/62210477.png</image> <image size="medium">http://userserve-ak.last.fm/serve/64/62210477.png</image>
<image size="large">http://userserve-ak.last.fm/serve/126/62210477.png</image>
的网址是什么访问图像大小的URL最好的方法=“大”上较新的Android版本的特定属性像ICS和果冻豆 * 编辑的问题* 作为答案中提供的答案我根据我的xml文件做了一些改变现在ii获取数据,但我想访问大图像的URL我需要做什么来获得大图像url
代码修改(我认为)
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
elementOn = true;
if (localName.equals("artist"))
{
data = new XMLGettersSetters();
} else if (localName.equals("image")) {
/**
* We can get the values of attributes for eg. if the CD tag had an attribute(<CD attr= "band">Akon</CD>)
* we can get the value "band". Below is an example of how to achieve this.
*
* String attributeValue = attributes.getValue("attr");
* data.setAttribute(attributeValue);
*
* */
}
}
/**
* This will be called when the tags of the XML end.
**/
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
elementOn = false;
/**
* Sets the values after retrieving the values from the XML tags
* */
if (localName.equalsIgnoreCase("name"))
data.setTitle(elementValue);
else if (localName.equalsIgnoreCase("listeners"))
data.setArtist(elementValue);
else if (localName.equalsIgnoreCase("url"))
data.setCountry(elementValue);
else if (localName.equalsIgnoreCase("image"))
data.setCompany(elementValue);
}
/**
* This is called to get the tags value
**/
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
if (elementOn) {
elementValue = new String(ch, start, length);
elementOn = false;
}
}
请帮我 谢谢
我去与你的链接,下载并提出根据我的链接做一些修改,但现在我得到的小图像的URL。我需要更改哪些代码才能获取大图片网址?请检查主要问题,我只是现在编辑 –
让我知道它是否工作 – DroidBot
老兄我卡住了,我无奈你可以帮助我,你可以写简单的代码,从这个链接检索大图像 http:// ws。 audioscrobbler.com/2.0/?method=track.getInfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=cher&track=believe –