If I have the following 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")
)
)
);
I'm after the output "Hello, Foo" using LINQ "." notation.
I can get "Hello" using
xDocument.Element("RootElement").Element("ChildElement").Attribute("Attribute1").Value;
I can get all of the Attributes using
xDocument.Element("RootElement").Elements("ChildElement").Attributes("Attribute1");
How can I get a list of the string values of the attributes so that I can join then as a comma separated list?