There is an xml file, you need to filter out and write from this file, the problem is that I only get 1 copy of it.

I'm having trouble getting the text. . Let's present the text in the form

<?xml version="1.0" encoding="utf-8"?> <response list="true"> <uid>12345</uid> <uid>55555</uid> <uid>54321</uid> </response> 

enter image description here

Closed due to the fact that off-topic participants Streletz , Alexey Shimansky , AK , Alexander Petrov , aleksandr barakin Jun 29 '17 at 21:59 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The message contains only the text of the task, in which there is no description of the problem, or the question is purely formal (" how do I do this task ") . To reopen the question, add a description of the specific problem, explain what does not work, what you see the problem. " - Streletz, AK, Alexander Petrov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    Why a screenshot? For example, I am too lazy to fill your XML manually. - VladD
  • Set the parameter v = 5.65, otherwise the old format and the version of VK API 3.0 are used, which will soon cease to be supported. - Peter Samokhin

1 answer 1

Well, like so.

Get a helper class

 public class Response { [XmlElement("uid")] public uint[] UidList { get; set; } [XmlAttribute("list")] public bool IsList { get; set; } } 

and deserialize:

 var seri = new XmlSerializer(typeof(Response), new XmlRootAttribute("response")); Response r = (Response)seri.Deserialize(stream); 

( stream - stream with your data, for example, file or network stream).

  • Does not work, everywhere is empty. - pavel1787mego
  • @ pavel1787mego: Then show your code. - VladD
  • @ pavel1787mego: I changed the response in the response code, try it. - VladD
  • I need from the server returned * .xml values ​​to filter what I need - pavel1787mego
  • @ pavel1787mego: Yes, and how will this information help to localize the problem? Give a reproducing example. - VladD