Reputation: 21
I have this XML that i want to parse in android (android studio). Somebody please help. AM really stuck here.
<?xml version="1.0" encoding="utf-8"?>
<message>
<isomsg direction="response">
<field id="0" value="ew8wqq"/>
<field id="2" value="kdlaka"/>
<field id="3" value="3388382"/>
<field id="4" value="9302"/>
<field id="7" value="02061212223721"/>
<field id="11" value="9029221"/>
<field id="12" value="38383"/>
<field id="24" value="0920202"/>
<field id="32" value="Texted"/>
<field id="37" value="10031503992006830"/>
<field id="41" value="93039292"/>
<field id="49" value="uehee"/>
<field id="56" value="938339939393"/>
<field id="68" value="Test: 5001115750001"/>
<field id="102" value="5001115750001"/>
<field id="27" value="001"/>
<field id="39" value="00"/>
<field id="48" value="Successful"/>
<field id="54" value="38288928383"/>
<field id="58" value="73838383"/>
</isomsg>
</message>
I will really appreciate. Thanks very much
Please find below the code that i use to get the response from the webservice
SoapObject request = new SoapObject("http://tempuri.org/", "PostRequest");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
PropertyInfo pi = new PropertyInfo();
pi.setName("IncomingXMLMessage");
pi.setValue(GenerateXML());
request.addProperty(pi);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSE = new HttpTransportSE("http://10.100.10.10:9000/IWalletService.asmx");
SoapObject response = null;
httpTransportSE.debug=true;
httpTransportSE.call("http://tempuri.org/PostRequest", envelope);
response = (SoapObject)envelope.bodyIn;
int totalCount = response.getPropertyCount();
String resultString=httpTransportSE.responseDump;
Log.d("XML data ", resultString);
XmlPullParserFactory factory = XmlPullParserFactory
.newInstance();
factory.setNamespaceAware(true);
XmlPullParser parser = factory.newPullParser();
String uResultString=resultString.replaceAll(">", ">");
String uResultStringFinal=uResultString.replaceAll("<","<");
parser.setInput(new StringReader(uResultStringFinal));
Upvotes: 1
Views: 1450
Reputation: 7311
That's a JPOS response XML nested in <message></message>
, not a SOAP XML,
see how JPOS does the parsing: https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/iso/packager/XMLPackager.java#L117
Upvotes: 0
Reputation: 1045
In order to parse your xml data in Android you'll obviously need to use a parser for that. Google suggests the XmlPullParser which I myself have found really useful. Google also provides some sample code for this here. Explaining everything here would just be a duplicate to other answers to this exact same question. If Google's code isn't enough you might search for some other tutorials on the web!
Upvotes: 2