I have this xml from which I am trying to grab the value in the node <ErrorCode> after investigating, i found it easier to use XDocument because it cleans any unwanted \r\n that the response from an api was giving me.. but now I am not sure how to retrieve that value using XDocument
<PlatformResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://platform.intuit.com/api/v1">
<ErrorMessage>OAuth Token rejected</ErrorMessage>
<ErrorCode>270</ErrorCode>
<ServerTime>2012-06-19T03:53:34.4558857Z</ServerTime>
</PlatformResponse>
I want to be able to take advantage of this call to get the value
XDocument xmlResponse = XDocument.Parse(response);
I can’t use XmlDocument because it does not clean the XML as it is doing it XDocument
Thank you
Since you have defined the Namespace, try the following code:
Or if you don’t want to use Namespace then: