Answer the question
In order to leave comments, you need to log in
How to parse xml in c#?
Always disliked parsing, hence the gap.
Now I do this, on the server I form a document like
<root>
<top>
<record>Ivan 500</record>
<record>Igor 250</record>
<record>Lena 750</record>
</top>
</root>
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(callbackLine.ToString());
XmlNodeList xmlnodli = xmldoc.SelectNodes("Root/top/record");
int num = xmlnodli.Count;
foreach (XmlNode xm in xmlnodli)
{
// тут xm.InnerText; содержит Lena 750 и.т.д
}
Answer the question
In order to leave comments, you need to log in
Here is the solution.)
XDocument doc = XDocument.Parse(callbackLine.ToString());
foreach (XElement el in doc.Root.Elements())
{
print(el.Attribute("username").Value + " " + el.Attribute("record").Value);
}
0. You form the file yourself and complain about its contents yourself ........
1. fill in the gaps
2. there is json, why xml ?
3. in any case, you can do deserialize and not suffer with query
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question