I have an xml document which looks like:
<?xml version="1.0" encoding="UTF-8"?>
<cbn:PaidOrderNotification xmlns:cbn="http://xml.test.com/3.12.0.0/test.xsd">
<cbn:NotificationDate>2016-08-01T07:28:46.679414Z</cbn:NotificationDate>
<cbn:Purchase cbt:Id="95368158" xmlns:cbt="http://xml.test.com/3.12.0.0/testTypes.xsd">
<cbt:Status>Test Order</cbt:Status>
<cbt:Items>
<cbt:Item cbt:RunningNo="1">
<cbt:ProductId>178732</cbt:ProductId>
<cbt:Payment cbt:SubscriptionId="S18767146">
<cbt:CancelUrl>https://store.test.com/</cbt:CancelUrl>
<cbt:ChangeUrl>https://test.com/</cbt:ChangeUrl>
</cbt:Payment>
</cbt:Item>
</cbt:Items>
<cbt:ExtraParameters />
</cbn:Purchase>
</cbn:PaidOrderNotification>
Using C#, I want to get the value inside <cbt:CancelUrl>
tag. How can I do that?
First read the xml
document like:
var doc = new XmlDocument();
doc.LoadXml(_xml);
then you could write:
string CancelUrl = doc.GetElementsByTagName("cbt:CancelUrl")[0].InnerText;
string ChangeUrl = doc.GetElementsByTagName("cbt:ChangeUrl")[0].InnerText;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With