我有搜索的东西,并有办法解析XMl
我上面所说的使用XMLPullParser
.
我在这里发布了解决方案,希望它可以帮助像我这样的人。
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(new StringReader (RESPONSE_STRNG_HERE));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT)
{
if(eventType == XmlPullParser.START_DOCUMENT)
{
System.out.println("Start document");
}
else if(eventType == XmlPullParser.END_DOCUMENT)
{
System.out.println("End document");
}
else if(eventType == XmlPullParser.START_TAG)
{
System.out.println("Start tag "+xpp.getName());
Log.e("Count ",""+xpp.getAttributeCount());
for(int ia=0;ia<xpp.getAttributeCount();ia++)
{
Log.e("Attribute Name ",xpp.getAttributeName(ia));
Log.e("Attribute Value ",xpp.getAttributeValue(ia));
}
}
else if(eventType == XmlPullParser.END_TAG)
{
System.out.println("End tag "+xpp.getName());
}
else if(eventType == XmlPullParser.TEXT)
{
Log.e("Text ",xpp.getText());
}
eventType = xpp.next();
}