У меня есть строка xml
?xml version="1.0" encoding="UTF-8"?>
<Entities TotalResults="64">
<Entity Type="test-set">
<ChildrenCount>
<Value>0</Value>
</ChildrenCount>
<Fields>
<Field Name="name">
<Value>default</Value>
</Field>
<Field Name="id">
<Value>0</Value>
</Field>
</Fields>
<RelatedEntities />
</Entity>
<Entity Type="test-set">
<ChildrenCount>
<Value>0</Value>
</ChildrenCount>
<RelatedEntities />
</Entity>
<singleElementCollection>false</singleElementCollection>
</Entities>
Я использую приведенный ниже код для преобразования XML-кода в json и использовал XMLDocument и JsonConvert.serializexmlNode ().
XmlDocument doc = new XmlDocument();
string xml = objHttpWebClient._retunResponseStream("http://test:8080/test-sets?fields=ID,Name", "GET", ASCIIEncoding.UTF8, cc);
doc.LoadXml(xml);
string jsonText = JsonConvert.SerializeXmlNode(doc);
return jsonText;
Я получаювывод, как показано ниже
{
"?xml": {
"@version": "1.0",
"@encoding": "UTF-8",
"@standalone": "yes"
},
"Entities": {
"@TotalResults": "64",
"Entity": [{
"@Type": "test-set",
"ChildrenCount": {
"Value": "0"
},
"Fields": {
"Field": [{
"@Name": "name",
"Value": "default"
},
{
"@Name": "id",
"Value": "0"
}]
},
"RelatedEntities": null
},
{
"@Type": "test-set",
"ChildrenCount": {
"Value": "0"
},
.........
...............................................................
однако я хочу игнорировать '@' и {"? Xml": {"@версия ":" 1.0 "," @encoding ":" UTF-8 "," @standalone ":" yes "},
часть из вывода json.