Trying to extract value from my xml with namespace c# -
I'm
Here I'm trying to get where I assume the XML paste. I need to find This is my code which I used to achieve my goal. I think from something where I am making a mistake for which the value of success is not being extracted but the exception has been removed. is not working line Please tell me where I am making a mistake. Thank you
& lt; Soapenv: envelope xmlns: soap = "http://schemas.xmlsoap.org/soap/envelope/" & gt; & Lt; Soapenv: header / & gt; & Lt; Soapenv: body & gt; & Lt; Ship: Ship Configurable Response xmlns: ship = "http://www.ups.com/XMLSchema/XOLTWS/Ship/v1.0" & gt; & Lt; General: Response xmlns: common = "http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0" & gt; & Lt; Common: ResponseStatus & gt; & Lt; Common: Code & gt; 1 & lt; / Common: Code & gt; & Lt; Common: Details & gt; Success & lt; / Common: Details & gt; & Lt; / Common: ResponseStatus & gt; & Lt; Common: TransactionReference & gt; & Lt; Common: CustomerContext / & gt; & Lt; Common: TransactionIdentifier & gt; Werqqa & lt; / Common: TransactionIdentifier & gt; & Lt; / Common: TransactionReference & gt; & Lt; / Common: reaction & gt; & Lt; Ship: ShipmentResults & gt; & Lt; Ship: NegotiatedRateCharges & gt; & Lt; Ship: TotalCharge & gt; & Lt; Ship: CurrencyCode & gt; Euro & lt; / Ship: CurrencyCode & gt; & Lt; Ship: MonetaryValue & gt; 15.50 & lt; / Ship: MonetaryValue & gt; & Lt; / Ship: TotalCharge & gt; & Lt; / Ship: NegotiatedRateCharges & gt; & Lt; / Ship: ShipmentResults & gt; & Lt; / Ship: ShipConfirmResponse & gt; & Lt; / Soapenv: Body & gt; & Lt; / Soapenv: envelope & gt;
success
words found if there is or not, I will pose and bring other data, such as monetary value.
XmlDocument xDoc = new XmlDocument (); XDoc.LoadXml (strResponse); XmlNamespaceManager xmlnsManager = New XmlNamespaceManager (xDoc.NameTable); XmlnsManager.AddNamespace ("soapenv", "http://schemas.xmlsoap.org/soaf/envelope/"); XmlnsManager.AddNamespace ("ship", "http://www.ups.com/XMLSchema/XOLTWS/Ship/v1.0"); XmlnsManager.AddNamespace ( "normal", "http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0"); String strHasSuccess = xDoc.SelectSingleNode ( "soapenv: Envelope / Soapenv: Body / ship: ShipConfirmResponse / common response / common ResponseStatus / General Description /", xmlnsManager) .ChildNodes [0] .Value; String sCurrencyCode = xDoc.SelectSingleNode ( "soapenv: Envelope / soapenv: Body / ship: ShipConfirmResponse / ship: ShipmentResults / ship: NegotiatedRateCharges / ship: TotalCharge / ship: CurrencyCode /", xmlnsManager) .ChildNodes [0] .Value; String sMonetaryValue = xDoc.SelectSingleNode ( "soapenv: Envelope / soapenv: Body / ship: ShipConfirmResponse / ship: ShipmentResults / ship: NegotiatedRateCharges / ship: TotalCharge / ship: MonetaryValue /", xmlnsManager) .ChildNodes [0] .Value;
string strHasSuccess = xDoc.SelectSingleNode ( "soapenv: Envelope / Sopenvi: Body / Ship Ship configure Response / Common: Response / Normal: Reaction space / General: Details / ", xmlnsManager). Hair node [0]. value;
If it's me, I will remove the /
trailing XPath, And instead of
: InnerText
child code [0]. Value
string strHasSuccess = xDoc.SelectSingleNode ( "Sabunen: Envelope / Sopenv: Body / Ship Ship Confirm Rispons / Common: Response / Common: Rispansstats / Common Details" , XMLLM manager). Inner text;
Comments
Post a Comment