如果我有以下 xml:
XDocument xDocument = new XDocument(
new XElement("RootElement",
new XElement("ChildElement",
new XAttribute("Attribute1", "Hello"),
new XAttribute("Attribute2", "World")
),
new XElement("ChildElement",
new XAttribute("Attribute1", "Foo"),
new XAttribute("Attribute2", "Bar")
)
)
);
我正在使用 LINQ “。”输出“Hello,Foo”。符号。
我可以得到“你好”使用
xDocument.Element("RootElement").Element("ChildElement").Attribute("Attribute1").Value;
我可以使用所有属性
xDocument.Element("RootElement").Elements("ChildElement").Attributes("Attribute1");
如何获取属性的字符串值列表,以便我可以作为逗号分隔列表加入?