V
V
Virtual Programmer2017-02-02 01:38:03
C++ / C#
Virtual Programmer, 2017-02-02 01:38:03

How to read string in xml and compare C#?

I have such a question, how to read the xml file on the site, and check the values ​​​​in the program itself.
Let's say the structure in the xml file

<?xml version="1.0" encoding="utf-8" ?>
<version>
  <myprogram>1.0.0.0</myprogram>
  <myupdater>1.1.0.0</myupdater>
  <suggestions>true</suggestions>
</version>

You need to read the suggestions line and make a check, if the value is true then the button is active, if false then the button is inactive
Code in the program
private void Main_Load(object sender, EventArgs e)
{
          XmlDocument serverdoc = new XmlDocument();
          localdoc.Load("http://мойсайт.ru/version.xml");
          // дальше что писать?
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rubka, 2017-02-02
@Rubka

var doc = XElement.Load("http://мойсайт.ru/version.xml");
var result = bool.Parse(doc.Element("suggestions").Value);

XmlDocument is a deprecated approach.
Better yet, deserialize into an object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question