我有试图用代码读取的 XML 字符串
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(XMLString);
XmlNode node = xmlDoc.SelectSingleNode("//cart/cart-item/url/text()");
Console.WriteLine(node.Value);
但node
始终为空。谁能解释什么是错的?
<order xmlns="http://ws.plimus.com">
<order-id>8301446</order-id>
<ordering-shopper>
<shopper-id>25879327</shopper-id>
</ordering-shopper>
<cart>
<charged-currency>USD</charged-currency>
<cart-item>
<sku>...</sku>
<quantity>1</quantity>
<url>
https://ws.plimus.com:443/services/2/subscriptions/9433117
</url>
<item-sub-total>9.00</item-sub-total>
</cart-item>
<tax>0.00</tax>
<tax-rate>0</tax-rate>
<total-cart-cost>9.00</total-cart-cost>
</cart>
</order>