Hi,
I am trying to add a new xElement to an existing xDocument but it needs to be added to a specific place in the structure.
Here is a snippet of the current structure, you can see that I have added ID xAttributes to the xElement td in order to specify the correct position for adding the new xElement.
from xfile in filePaths
select new XElement("tr",
new XElement("td", new XAttribute("ID", 1), new XAttribute("style", "border-width: 1px; padding: 10px; border-style: inset; border-color: gray; background-color: white;"), new XAttribute("align", "center"), new XAttribute("valign", "middle"),
new XElement("a", new XAttribute("href", xfile), new XAttribute("target", "_new"), new XElement("img", new XAttribute("src", xfile), new XAttribute("width", "100"), new XAttribute("border", "0"))),
new XElement("td", new XAttribute("ID", 2), new XAttribute("style", "border-width: 1px; padding: 10px; border-style: inset; border-color: gray; background-color: white;"), new XAttribute("align", "center"), new XAttribute("valign", "middle"),
new XElement("b", Path.GetFileNameWithoutExtension(xfile))),
new XElement("td", new XAttribute("ID", 3), new XAttribute("style", "border-width: 1px; padding: 10px; border-style: inset; border-color: gray; background-color: white;"), new XAttribute("align", "center"), new XAttribute("valign", "middle")
)))))))));
I wish to add a new xElement of b directly after the xElement td that has an xAttribute ID=3.
Something along the lines of this
xDocument.Root.Element("td").Add(
new XElement("b", DateTaken));
but unfortunately this is not specific to the xElement td with xAttribute ID=3.
Any help would be appreciated.
Kind regards..,