I have an xml file and I show the small part of it, to show the content what I want
Call getAttributeValue like the following
parser.getAttributeValue(null, "url")
inside of your if statement. Make sure getEventType()
is equal to START_TAG since your current if statement will also evaluate to true when your parser is set to the END_TAG portion of your media:content (which would give you a -1 attribute count).
EDIT Since you are having so much trouble, I hope this little test function does what you want:
public void parseXml() throws XmlPullParserException, IOException
{
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
parser.setInput(new StringReader(
""
+ "Getty Images file "
+ "2010 Getty Images "
+ "
]]> "
+ " "));
while (!"media:content".equals(parser.getName()) && parser.getEventType() != XmlPullParser.START_TAG) {
parser.next();
}
Log.d("media count -->", parser.getAttributeValue(null, "url"));
}