Trying to add an xml element and attribute between an existing one.
I have xml template that looks lik e this:
<INPUT>
<LOGIN user="cat" password="meow" />
<REC>
</REC>
</INPUT>
I’m looking to add an element and atribute between <REC></REC>
treid formattging soemthing like this but it sticks it after LOGIN not REC
IEnumerable<XElement> list = doc.Element("INPUT").Elements("LOGIN");
var addElement = new XElement("an", new XAttribute("id", i));
list.Last().AddAfterSelf(addElement);
It sounds like you’re trying to add it as a child of
REC. That’s easy: