I have the following XML, in a RestSharp RestRequest.Content object. How can i traverse it, or change to JSON, to get the FULLNAME node out, in C#?
<ns1:MT_Get_Name_Res xmlns:ns1="http://hse.pd.com">
<fullname>Gandalf Elizabeth Cfieulle02</fullname>
<error>Success</error>
</ns1:MT_Get_Name_Res>
Things I have tried already:
JSON - returns a screwed up JSON object, which then fails to parse to my local object
XmlDocument doc = new XmlDocument();
doc.LoadXml(response.Content);
string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);
EmployeeSAPObject emp = JsonConvert.DeserializeObject<EmployeeSAPObject>(json);
C# XML parsing - fullname is null:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(response.Content); // suppose that myXmlString contains "<Names>...</Names>"
XmlNodeList xnList = xmlDoc.SelectNodes("/MT_Get_Name_Res/fullname");
foreach (XmlNode xn in xnList)
{
string fullName = xn["fullname"].InnerText;
}
Here is my EmployeeSAPObject class
public class EmployeeSAPObject
{
public string fullname { get; set; }
public string error { get; set; }
}