I have an XML like this:
<job>
<properties>
<name>jobid</name>
<value>81963</value>
</properties>
<properties>
<name>status</name>
<value>complete</value>
</properties>
<properties>
<name>date</name>
<value>2018-07-30</value>
</properties>
</job>
<job>
<properties>
<name>jobid</name>
<value>81194</value>
</properties>
<properties>
<name>status</name>
<value>complete</value>
</properties>
<properties>
<name>date</name>
<value>2018-07-30</value>
</properties>
</job>
And what I need to happen is to get all the properties of each job. I have had a hard time looping through its nodes and childnodes but couldn't get the exact logic of this. What I really need to happen is to convert this data to something like:
[{
"jobid": "81963",
"status": "complete",
"date": "2018-07-30"
},
{
"jobid": "81194",
"status": "complete",
"date": "2018-07-30"
}]
I have already tried this:
foreach (XmlNode child in xn.SelectNodes("properties"))
{
arrd.Add(checkNullValue(child["value"]));
}
arrd2.AddRange(arrd);
//For Converting to JSON
try
{
var jobVals = getXmlData("test", "testuser2", "654321", "Sources/soapRequest.xml");
Response.Write(jobVals.Count);
//JSONIZE list(the XML)
string json = JsonConvert.SerializeObject(jobVals);
Response.Write(json);
}
catch (Exception ex)
{
Response.Write(ex);
}
Please Help.