I have a webservice for rating it return <Score>float</Score>
while retrieving this using XML parser always return null[0]. I don't have any idea. My code is below:
public static String parse(InputStream is)
{
XmlPullParserFactory factory = null;
try {
factory = XmlPullParserFactory.newInstance();
} catch (XmlPullParserException e1) {
// TODO Auto-generated catch block
Log.v(TAG,"Exception in Factory pull");
}
factory.setNamespaceAware(true);
XmlPullParser parser = null;
try {
parser = factory.newPullParser();
} catch (XmlPullParserException e1) {
Log.v(TAG,"Exception in parser pull");
}
String rating = "";
//XmlPullParser parser = Xml.newPullParser();
Log.v("XMLParser:", parser.toString());
try
{
// auto-detect the encoding from the stream
parser.setInput(is, null);
int eventType = parser.getEventType();
//Message currentMessage = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done)
{
String name = null;
switch (开发者_StackOverflow中文版eventType)
{
case XmlPullParser.START_DOCUMENT:
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("Score"))
{
rating = parser.nextText();
Log.v("Rating", rating);
done = true;
}
break;
case XmlPullParser.TEXT:
Log.v(TAG,"Node value:"+parser.getText());
case XmlPullParser.END_TAG:
break;
}
eventType = parser.next();
}
}
catch (Exception e)
{
rating = "0";
}
return rating;
}
My Web service xml is :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetRatingDResponse xmlns="http://tempuri.org/">
<GetRatingDResult>
<Votes>int</Votes>
<Score>float</Score>
</GetRatingDResult>
</GetRatingDResponse>
</soap:Body>
</soap:Envelope>
Can any body tell me what is wrong with this code?
精彩评论