丟失時負載的XmlDocument我有以下代碼:根元素是從流
var XmlDoc = new XmlDocument();
Console.WriteLine();
Console.WriteLine(response.ReadToEnd());
Console.WriteLine();
// setup the XML namespace manager
XmlNamespaceManager mgr = new XmlNamespaceManager(XmlDoc.NameTable);
// add the relevant namespaces to the XML namespace manager
mgr.AddNamespace("ns", "http://triblue.com/SeriousPayments/");
XmlDoc.LoadXml(response.ReadToEnd());
XmlElement NodePath = (XmlElement)XmlDoc.SelectSingleNode("/ns:Response", mgr);
while (NodePath != null)
{
foreach (XmlNode Xml_Node in NodePath)
{
Console.WriteLine(Xml_Node.Name + " " + Xml_Node.InnerText);
}
}
我越來越:
缺少根元素。
在:
XmlDoc.LoadXml(response.ReadToEnd());
我的XML看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://triblue.com/SeriousPayments/">
<Result>0</Result>
<Message>Pending</Message>
<PNRef>230828</PNRef>
<ExtData>InvNum=786</ExtData>
</Response>
我迷路了。有人能告訴我我做錯了什麼嗎?我知道我之前有這個工作,所以我不知道我搞砸了什麼。
一如既往,謝謝!
*我之所以編輯後,我得到了我的答案* *
我需要改變線路:
XmlElement NodePath = (XmlElement)XmlDoc.SelectSingleNode("/ns:Response");
到:
XmlElement NodePath = (XmlElement)XmlDoc.SelectSingleNode("/ns:Response", mgr);
這沒有它就無法工作。
什麼Console.WriteLine(response.ReadToEnd());輸出? – DoctorMick
什麼是響應類型? – DeveloperX
您如何期待「實質性」來自** steam **? :-)(對不起,忍不住...) –