XDocumentには、 'x'、 'y'、 'x1'、 'y1'、 'z'、および ' Z1' :すべての要素をループして、特定の属性をチェックせず、文書全体からのx 『属性の値のみを抽出するための最も簡単な推奨される方法は何XDocument全体からの属性の抽出
<?xml version="1.0" encoding="utf-8"?>
<shapes>
<shape>
<connections />
<foreground>
<strokewidth width="0.1" />
<path>
<move x="1395.6" y="84.6" />
<line x="80.1" y="84.6" />
<curve x1="75.1" y1="84.6" x2="71.1" y2="88.6" x3="71.1" y3="93.6" />
<line x="71.1" y="402.6" />
<close />
</path>
<fillstroke />
</foreground>
</shape>
</shapes>
』?座標であるため :
float[] x= {1395.6, 80.1, 71.1};
float[] x1 = {75.1};
そして、 'Y'、 'Y1' の同じ、...
EDIT:与えられたXMLは、理想的には 'X' 座標のリストでしまいます常に「葉」のXML要素で、私は最終的に使用:
return fileXml.Root.Descendants()
.Where(e => e.HasElements == false) // leaf element
.Where(e => e.Attribute("x") != null)
.Select(c => c.Attribute("x").Value).Select(float.Parse)
.ToList(); // or .ToArray();
それは同様にヘルパー関数でラップすることができます。