以下は、JSON 応答のタイプです。
{
"?xml":{
"@version":"1.0",
"@encoding":"iso-8859-1"
},
"xmlreport":{
"@title":"ABC: TEST Most Saved2",
"@dates":"Week of May 19,2013",
"columns":{
"column":[
{
"@name":"Page",
"@type":"dimension",
"#text":"Page"
},
{
"@name":"Events",
"@type":"metric",
"@hastotals":"true",
"#text":"Events"
}
]
},
"rows":{
"row":[
{
"@rownum":"1",
"cell":[
{
"@columnname":"page",
"@csv":"\"http://www.ABC.com/profile/recipebox\"",
"#text":"http://www.ABC.com/profile/recipebox"
},
{
"@columnname":"events",
"@percentage":"\"0.1%\"",
"#text":"489"
}
]
},
{
"@rownum":"2",
"cell":[
{
"@columnname":"page",
"@csv":"\"http://www.ABC.com/recipes/peanut-butter-truffle-brownies/c5c602e4-007b-43e0-aaab-2f9aed89524c\"",
"#text":"http://www.ABC.com/recip...c602e4-007b-43e0-aaab-2f9aed89524c"
},
{
"@columnname":"events",
"@percentage":"\"0.0%\"",
"#text":"380"
}
]
}
]
},
"totals":{
"pagetotals":{
"total":{
"@columnname":"events",
"@value":"1820.000000",
"#text":"1,820 (0.2%)"
}
},
"reporttotals":{
"total":{
"@columnname":"events",
"@value":"7838.000000",
"#text":"7,838 (0.8%)"
}
},
"timeperiodtotals":{
"total":{
"@columnname":"events",
"@value":"955774.000000",
"#text":"955,774 (100.0%)"
}
}
}
}
}
オブジェクトを解析できません。解析後に属性と要素を読み取る方法を教えてください。私はC#を使用しています
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(XML);
string jsonText = JsonConvert.SerializeXmlNode(doc);
//var result = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(jsonText, "xmlreport");
var results = JsonConvert.DeserializeObject<dynamic>(jsonText);
JToken token = JObject.Parse(jsonText);
var report = token["xmlreport"];
}