我是 C# Soap Web 服務(wù)的新手。我可以提出肥皂請求。但不確定如何解析下面的肥皂響應(yīng)以獲取 OrderId 例如。<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <OrderCreateByChannelResponse xmlns="http://retailexpress.com.au/"> <OrderCreateByChannelResult> <Response xmlns=""> <OrderCreate> <Customer> <Result>Success</Result> <ExternalCustomerId>170</ExternalCustomerId> <CustomerId>300941</CustomerId> </Customer> <Order> <Result>Success</Result> <ExternalOrderId>INT_3673_ccv_20190926132240</ExternalOrderId> <OrderId>19-00033544</OrderId> <ChannelID>1</ChannelID> </Order> <OrderItems> <OrderItem> <Result>Success</Result> <ExternalOrderItemId></ExternalOrderItemId> <ProductId>126659</ProductId> <OrderId>19-00033544</OrderId> </OrderItem> </OrderItems>
1 回答

縹緲止盈
TA貢獻(xiàn)2041條經(jīng)驗 獲得超4個贊
嘗試這樣
XDocument doc = XDocument.Parse(testXML1);
XNamespace ns = doc.Root.GetDefaultNamespace();
string ExternalCustomerId="";
string CustomerId="";
foreach (XElement element in doc.Descendants(ns + "ExternalCustomerId"))
{
ExternalCustomerId = element.Value;
}
foreach (XElement element in doc.Descendants(ns + "CustomerId"))
{
CustomerId = element.Value;
}
- 1 回答
- 0 關(guān)注
- 398 瀏覽
添加回答
舉報
0/150
提交
取消