Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, your xml should look like this:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;Contact_x0020_Form&gt; &lt;Contacts&gt; &lt;Contact&gt; &lt;Id&gt;1&lt;/Id&gt; &lt;Name&gt;vicky1kumar&lt;/Name&gt; &lt;Phone&gt;248847227&lt;/Phone&gt; &lt;/Contact&gt; &lt;Contact&gt; &lt;Id&gt;2&lt;/Id&gt; &lt;Name&gt;vicky1kumar2kumar&lt;/Name&gt; &lt;Phone&gt;725228355&lt;/Phone&gt; &lt;/Contact&gt; &lt;/Contacts&gt; &lt;/Contact_x0020_Form&gt; </code></pre> <p>Second, define <code>serialization classes</code> something like :</p> <pre><code>[XmlRoot(ElementName = "Contact_x0020_Form")] public class Root { [XmlElement("Contacts")] public Contacts contacts{get;set;} } public class Contacts { public List&lt;Contact&gt; contacts {get;set;} } public class Contact { [XmlElement("Id")] public int Id {get;set;} [XmlElement("Name")] public string Name {get;set;} [XmlElement("Phone")] public string Phone {get;set;} } </code></pre> <p>and your <code>helper classes</code></p> <pre><code>public static class serialize { public static T Deserialize&lt;T&gt;(string path) { T result; using (var stream = File.Open(path, FileMode.Open)) { result = Deserialize&lt;T&gt;(stream); } return result; } public static void Serialize&lt;T&gt;(T root, string path) { using (var stream = File.Open(path, FileMode.Create)) { var xmlSerializer = new XmlSerializer(typeof(T)); xmlSerializer.Serialize(stream, root); } } public static T Deserialize&lt;T&gt;(Stream stream) { var xmlSerializer = new XmlSerializer(typeof(T)); return (T)xmlSerializer.Deserialize(stream); } } </code></pre> <p>And, finally your func:</p> <pre><code>static void Main() { var a = serialize.Deserialize&lt;Root&gt;("input.xml"); //xml file name given here. Console.WriteLine(a.contacts); } </code></pre> <p>This is how you should proceed. Then on, you can get the list of objects that you want.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload