3
一直在閱讀本文和其他論壇幾個小時和幾天,無法找到我的肥皂響應的解決方案。一直試圖各種答案在這裏,但無法解析我的回答:(monodevelop解析肥皂響應
我的迴應:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getLocationsResponse xmlns="http://getlocations.ws.hymedis.net">
<locs>
<loc>
<name>Zeebrugge Wielingen Zand</name>
<abbr>ZWZ</abbr>
<RDX>1435.8</RDX>
<RDY>378678.6</RDY>
<params>
<param>GHs</param>
<param>SS10</param>
</params>
</loc>
</locs>
</getLocationsResponse>
</soapenv:Body>
</soapenv:Envelope>
我的C#代碼到目前爲止(PARAM soapresponse是字符串格式全soapresponse)我的反應是正確的,所以完整的XML SOAP響應,但不能分析它好
public void readXml(string soapresponse){
XmlDocument xmlresponse = new XmlDocument();
xmlresponse.LoadXml(soapresponse);
XmlNamespaceManager nsmanager = new XmlNamespaceManager(xmlresponse.NameTable);
nsmanager.AddNamespace ("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
XmlNodeList nodes = xmlresponse.SelectNodes("/soapenv:Envelope/soapenv:Body/getLocationsResponse/locs/loc", nsmanager);
List<Locatie> locatielijst = new List<Locatie>();
// loop
foreach(XmlNode node in nodes){
string loc_naam = node["name"].InnerText;
string loc_code = node["abbr"].InnerText;
...
Locatie locatie = new Locatie();
locatie.loc_naam = loc_naam;
locatie.loc_code = loc_code;
...
locatielijst.Add (locatie);
}
Console.WriteLine(locatielijst.Count.ToString());
foreach(Locatie loc in locatielijst){
Console.WriteLine (loc.loc_code);
}
}
但每次我list.count返回0時 - >所以他們沒有數據.. plz幫助我走出