There is an XML file view:
& lt; time & gt;
& lt; Name & GT; Birch & Lt; / Name & GT;
& lt; Age & gt; 3 & lt; / age & gt;
& lt; node & gt;
& lt; Name & gt; List1 & lt; / Name & gt;
& lt; Age & gt; 1 & lt; / age & gt;
& lt; / node & gt;
& lt; node & gt;
& lt; Name & gt; List2 & lt; / Name & gt;
& lt; Age & gt; 1 & lt; / age & gt;
& lt; / node & gt;
& lt; Tree & GT;
& lt; Name & gt; Peach & Lt; / Name & GT;
& lt; Age & gt; 3 & lt; / age & gt;
& lt; node & gt;
& lt; name & gt; sheet11 & lt; / name & gt;
& lt; Age & gt; 1 & lt; / age & gt;
& lt; / node & gt;
& lt; node & gt;
& lt; Name & gt; List22 & lt; / Name & gt;
& lt; Age & gt; 1 & lt; / age & gt;
& lt; / node & gt;
& lt; / tree & gt;
& lt; / tree & gt;
How to go through the document and fill in the form structures:
struct tree
{
INT NAME;
Int Age.
}
Struct Node.
{
INT NAME;
INT AGE;
}
Tree T;
Node N;
If (& lt; Tree & GT;)
T.NAME = NAME;
T.age = AGE;
ELSE.
N.Name = Name;
N.age = AGE;
Answer 1, Authority 100%
In this way, http://ideone.com/y8kog .
using system;
Using System.Collections.Genic;
Using System.xml;
Using System.xml.Serialization;
Using System.io;
Using System.Linq;
Public Class Node.
{
Public String Name;
Public String Age;
}
Public Class Tree.
{
Public String Name;
Public int age;
[Xmlelement ("Node")]
Public List & LT; Node & GT; nodes;
[Xmlelement ("Tree")]
Public List & LT; Tree & GT; Trees;
}
Public Class Test
{
Public Static Void Main ()
{
var xml = @ "& lt; xml version =" "1.0" "encoding =" "UTF-8" "? & gt; ...";
VAR Reader = New StringReader (XML);
VAR Result = (Tree) New Xmlserializer (Typeof (Tree). Deserialize (Reader);
}
}
Answer 2
Use Linq to XML. Very comfortable thing.
Here is an article on this topic http://habrahabr.ru/post/24673/