I have an xml with:
string xml = "<?xml .... />" +
"<root>" +
"<paramFile version=1.0>" +
"<stuff />" +
"</paramFile>" +
"<paramFile version=1.0>" +
"<stuff />" +
"</paramFile>" +
"</root>";
Then I convert to JSON and parse it:
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
string jsonText = JsonConvert.SerializeXmlNode(doc).Replace("\"@", "\"");
JToken token = JObject.Parse(jsonText);
How do I get the count of the number of paramFiles in my JSON?
Something like this works (And I find is easiest). Mostly depends how deep your tree is going to be.
token["root"]["paramFile"].Count();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With