Answers for "read xmldocument c#"

C#
3

How to read a XML on C#

XmlDocument doc = new XmlDocument();
            doc.Load(path);
            doc.Save(Console.Out);

            foreach (XmlNode node in doc.DocumentElement)
            {
                string word_name = node.Attributes[0].Value;
                string word_translation = node["name of node"].InnerText;
            }
Posted by: Guest on February-12-2021
0

c# xmldocument from file

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("your file path");
Posted by: Guest on August-18-2020
0

xmldocument to c# object

void Main()
{
   String aciResponseData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag><bar>test</bar></tag>";
   using(TextReader sr = new StringReader(aciResponseData))
   {
        var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MyClass));
        MyClass response =  (MyClass)serializer.Deserialize(sr);
        Console.WriteLine(response.bar);
   }
}

[System.Xml.Serialization.XmlRoot("tag")]
public class MyClass
{
   public String bar;
}
Posted by: Guest on December-21-2020

C# Answers by Framework

Browse Popular Code Answers by Language