我有這個XML,我想在android(android studio)中解析。有人請幫忙。 AM真的停留在這裏。在Android中解析ISO8583 XML(使用android studio)
<?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>
我會很感激。非常感謝
請找到我用它來獲得從WebService
SoapObject請求=新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));
我已經看過給出的解釋和樣品和我似乎無法聯繫。我不明白。 Crosswind,請協助 – Turbo
從o web服務獲取此XML並轉換爲字符串。 response =(SoapObject)envelope.bodyIn; int totalCount = response.getPropertyCount(); String resultString = httpTransportSE.responseDump;所以我有一個問題發佈這個值到這個方法private String readFields(XmlPullParser parser),......它只接受分析器。如何將此xml字符串轉換爲解析器? – Turbo
我真的不知道你在那裏做什麼。您通常會實例化解析器等,然後將輸入設置爲該解析器,該解析器需要Reader或InputStream。也許我的例子會幫助你 - https://github.com/Crosswind/Vertretungsplan/blob/master/app/src/main/java/de/gymnasium_beetzendorf/vertretungsplan/XMLParser.java 你究竟從哪裏獲得xml?下載的文件? – Crosswind