using System;
using System.Xml ;
public class Test
{
public static void Main( )
{
var xml = @"<?xml version=" "1.0" "?>
<listOfItems>
<Item id=" "1" ">
<attribute1 type=" "foo" "/>
<attribute2 type=" "bar" "/>
<property type=" "x" "/>
<property type=" "y" "/>
<attribute3 type=" "z" "/>
</Item>
<Item id=" "2" ">
<attribute1 type=" "aaa" "/>
<attribute2 type=" "bbb" "/>
<property type=" "ccc" "/>
<property type=" "ddd" "/>
<attribute3 type=" "ee" "/>
</Item>
</listOfItems>" ;
var xmldoc = new XmlDocument( ) ;
xmldoc.LoadXml ( xml) ;
XmlNodeList nodes = xmldoc.GetElementsByTagName ( "Item" ) ;
foreach( XmlNode node in nodes)
{
Console.WriteLine ( "Node={0} type id={1}" , node.Name , node.Attributes [ "id" ] .Value ) ;
foreach( XmlNode child in node.SelectNodes ( "property" ) )
{
Console.WriteLine ( " Name={0} type attribute={1}" , child.Name , child.Attributes [ "type" ] .Value ) ;
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uWG1sOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciB4bWwgPSBAIjw/eG1sIHZlcnNpb249IiIxLjAiIj8+CjxsaXN0T2ZJdGVtcz4KICA8SXRlbSBpZD0iIjEiIj4gCiAgICA8YXR0cmlidXRlMSB0eXBlPSIiZm9vIiIvPgogICAgPGF0dHJpYnV0ZTIgdHlwZT0iImJhciIiLz4KICAgIDxwcm9wZXJ0eSB0eXBlPSIieCIiLz4KICAgIDxwcm9wZXJ0eSB0eXBlPSIieSIiLz4KICAgIDxhdHRyaWJ1dGUzIHR5cGU9IiJ6IiIvPgogIDwvSXRlbT4KICA8SXRlbSBpZD0iIjIiIj4KICAgIDxhdHRyaWJ1dGUxIHR5cGU9IiJhYWEiIi8+CiAgICA8YXR0cmlidXRlMiB0eXBlPSIiYmJiIiIvPgogICAgPHByb3BlcnR5IHR5cGU9IiJjY2MiIi8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