Best way to check for an XML Element

DominiqueR2000

New Member
I have code that posts XML to a WebResponse and gets an output/response of Xml data back. If their is an error when posting it results in XML output response like this:\[code\]<OUTPUT version="1.0"> <ERROR type="Incomplete">Invalid data</ERROR></OUTPUT>\[/code\]The first Element will be "ERROR" if an error is encountered, if no error is encountered the first Element will be "INFO". Is their a way check if the webResponse XML first Element is "ERROR" and if so grab the type attribute and the text "Invalid Data" inside the tags. If it's not error do nothing. Not sure how to do an if on parsing xml data.\[code\]XDocument doc = XDocument.Parse(XmlResponse)errorMsg = doc.Parse(XMLResponse).Descendants("ERROR").Select(e => (string)e.Attribute("type")).First().ToString();\[/code\]
 
Back
Top