public override XElement createXmlElement()
{
XElement XShape = new XElement("Shape", new XAttribute("Name", "freeline"),
new XElement("Pen_Details",
new XAttribute("PenColor", this.PenColor.ToArgb().ToString("X")),
new XAttribute("PenWidth", this.PenWidth),
(for(int i = 0; i < FreeList.Count; i++)
{
new XElement("Point", new XAttribute("X", this.Pt1.X), new XAttribute("Y", this.Pt1.Y));
}));
return XShape;
}
我需要在循环中添加点。我怎样才能做到这一点?
以下代码的输出:
<Shapes>
<Shape Name="freeline">
<Pen_Details PenWidth="2" PenColor="FFFF0000">
<Point> X='127' Y='71'</Point>
<Point> X='128' Y='71'</Point>
<Point> X='130' Y='71'</Point>
</Pen_Details>
</Shape>
</Shapes>