Hi,
I am having major headaches with XmlNode.InsertA fter. This is the
format of my XML document
<?xml version="1.0" encoding="utf-8"?>
<Team name="Team">
<Players>
<Player>
<name> GK</name>
<age> 28 </age>
<position> GK</position>
</Player>
<Player>
<name> P1</name>
<age> 22 </age>
<position> GK</position>
</Player>
<Player>
<name> P2</name>
<age> 32 </age>
<position> D</position>
</Player>
<Player>
<name> P3</name>
<age> 27 </age>
<position> D</position>
</Player>
</Players>
<Staff>
<Manager>
<name> Manager </name>
</Manager>
<Assistant-Manager>
<name> Assistant Manager </name>
</Assistant-Manager>
<Physio>
<name> Physio </name>
</Physio>
</Staff>
</Team>
I can locate a node but when I try to do an insert after on that node
I get "The reference node is not a child of this node". This is the
code
XmlNode root2 = doc2.DocumentEl ement;
//Create a new Element.
XmlElement newPlayer = doc2.CreateElem ent ("Player");
//doc2.DocumentEl ement.FirstChil d.AppendChild (newPlayer); - this
works but I want to be able to control where exactly the new Player
goes
doc2.InsertAfte r (newPlayer, doc2.DocumentEl ement.FirstChil d);
// I have tried finding a Player Node and calling insertafter using
that node as a reference but that fails as well. I'd appreciate any
help.
Also If anyone knows where I can find the Syntax for XPathExpression s
please reply.
All the best,
JD