Hi,
I've a simple XML tree that is essentially.
<?xml version="1.0"?>
<Project>
<Version Version="1.001" />
<Platform Name="Platform1"/>
<Platform Name="Platform2" />
</Project>
Now I have the following code.
XmlNode destinationProjectNode = doc1.SelectSingleNode("//Project");
string xPath = string.Format("{Platform}[@Name='Platform1']");
XmlNode destinationXmlNode = destinationProjectNode.SelectSingleNode(xPath);
This will retrieve the correct node as you'd expect, however in certain
cases and I can't find out why, is the node that is returned has null set
for it's parent, which means it can't be deleted because it thinks it's not
a child of any given node, I checked the body of Project and law and behold
it wasn't there, but, if it's it wasn't there, how did SelectSingleNode pick
it up ?? :/
Any pointers on this would be helpful.
Actually thinking about it, when you do a removechild node, is there
anything else you have to do to remove it from the xml ? as I know when you
bring one node in from a different xml you have to do an importnode and then
an appendchild, so I'm wondering if the node is still lingering around
somewhere but it's actually attached to anything, then again, you'd expect
selectsinglenode not to find it.. sorry, I'm just confused :)
Regards,
PT.