Accepted answer

Select page which you need

XDocument xdoc = XDocument.Load("Test.xml");
int pageId = 2;
var page = xdoc.Descendants("Page")
                .FirstOrDefault(p => (int)p.Element("Id") == pageId);

And then add content to this page element (if any):

if (page != null)
    // add to Hotspots element
        .Add(new XElement("Hotspot",
                 new XElement("X", x),
                 new XElement("Y", y),
                 new XElement("Shape", "Circle"),
                 new XElement("TargetId", nNodeID)));


Your code adds new Hotspot element to page, instead of adding content to existing Hotspots element.

Related Articles