编程Langauge - c#。
显示下面提到的错误。
Unhandled Exception: System.Xml.XPath.XPathException: Namespace Manager or XsltC
ontext needed. This query has a prefix, variable, or user-defined function.
这是我编写的用于返回内部文本的代码。
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"C:\test\myfile.xml");
var nsmgr = new XmlNamespaceManager(xmldoc.NameTable);
nsmgr.AddNamespace("env", "http://schemas.xmlsoap.org/soap/envelope/");
nsmgr.AddNamespace("ns1", "http://sse/ECOM:1.0:schema:messages");
nsmgr.AddNamespace("wsa", "http://www.w3.org/2005/08/addressing");
XmlNode node = xmldoc.SelectsingleNode("/*/env:Body/env:response/env:customerAccountsGrp[1]/env:customerAccountID");
Console.WriteLine(xmldoc.SelectSingleNode("/*/env:Body/env:response/env:customerAccountsGrp[1]/env:customerAccountID").InnerText);
这是肥皂消息
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:5C4DCC70E6F411E69F7EF5AAD683B4B3</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo><wsa:FaultTo> <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:FaultTo>
</env:Header>
<env:Body>
<response
xmlns:ns0="urn:sse:ECOM:1.0:schema:messages"
xmlns="urn:sse:ECOM:1.0:schema:messages">
<ns0:customerAccountsGrp>
<ns0:customerAccountID>1212121212</ns0:customerAccountID>
<ns0:customerAccountStatus>AC</ns0:customerAccountStatus>
<ns0:serviceType>AB</ns0:serviceType>
<ns0:brandCode>XXX </ns0:brandCode>
<ns0:affinityType> </ns0:affinityType>
<ns0:paymentType>VV</ns0:paymentType>
</ns0:customerAccountsGrp><ns0:customerAccountsGrp>
<ns0:customerAccountID>4545454545445</ns0:customerAccountID>
<ns0:customerAccountStatus>BC</ns0:customerAccountStatus>
<ns0:serviceType>FH</ns0:serviceType>
<ns0:brandCode>SE</ns0:brandCode>
<ns0:affinityType></ns0:affinityType>
<ns0:paymentType>NM</ns0:paymentType>
</ns0:customerAccountsGrp>
有人可以帮我解决这个问题吗? 最诚挚的问候。