C# XML多属性

C# XML多属性,c#,xml,parsing,C#,Xml,Parsing,我得到了这样的东西: <item name="Whatever"> <Point x="12312" y="24234" /> <Point x="242342" y="2142" /> </item> 如果数组包含名称和点列表,我需要在数组中解析此项 我以前没有真正使用xml 这是到目前为止我的代码 XmlReader reader = XmlReader.Create("Gestures.xml"); while (rea

我得到了这样的东西:

<item name="Whatever">
    <Point x="12312" y="24234" />
    <Point x="242342" y="2142" />
</item>

如果数组包含名称和点列表,我需要在数组中解析此项

我以前没有真正使用xml

这是到目前为止我的代码

XmlReader reader = XmlReader.Create("Gestures.xml");
while (reader.Read())
{
    KnownGestures temp = new KnownGestures();
    IList<Point> GesturePath = new List<Point>();
    // Only detect start elements.
    if (reader.IsStartElement())
    {
        // Get element name and switch on it.
        switch (reader.Name)
        {
            case "Gesture":
                // Detect this element.
                temp.GestureName = reader["Name"];
                break;
            case "Point":
                var XValue = reader["X"];
                var YValue = reader["Y"];
                Point tempPoint = new Point {X = double.Parse(XValue), Y = double.Parse(YValue)};
                GesturePath.Add(tempPoint);
                temp.GesturePath = GesturePath;
                break;
        }

        GesturesList.Add(temp);
    }
}
XmlReader=XmlReader.Create(“signatures.xml”);
while(reader.Read())
{
KnownGestures temp=新的KnownGestures();
IList GesturePath=新列表();
//仅检测开始元素。
if(reader.IsStartElement())
{
//获取元素名称并打开它。
开关(reader.Name)
{
案例“手势”:
//检测此元素。
temp.GestureName=reader[“Name”];
打破
案例“要点”:
var XValue=读卡器[“X”];
var YValue=读卡器[“Y”];
点tempPoint=新点{X=double.Parse(XValue),Y=double.Parse(YValue)};
添加(临时点);
temp.GesturePath=GesturePath;
打破
}
手势列表添加(临时);
}
}
编辑后的

我发现更容易使用

var points = XDocument.Load(filename)
            .Descendants("Point")
            .Select(p => new Point((int)p.Attribute("x"), (int)p.Attribute("y")))
            .ToList();

现在不是开始使用它的好时机吗?到目前为止你做了什么?可能是我编辑的文章的副本,也许后面的代码会有所帮助