2005-01-13, 01:30 PM
im trying to delete a node, eg "/a/b/c/d" ie deleting the d child.
ive tried using
doc.RemoveChild(doc.SelectSingleNode("/a/b/c/d"
) //error not achild
then tried:
XmlNode node = doc.SelectSingleNode("/a/b/c"
)
node.RemoveChild(node.SelectSingleNode("/d"
) //error not a child
so ive had to use
XmlNode baseNode = doc.SelectSingleNode("/a/b/c"
;
foreach(XmlNode node in baseNode.ChildNodes){
if(node.Name == "d"![Wink Wink](https://forums.nextpvr.com/images/smilies/wink.png)
baseNode.RemoveChild(node);
}
which works, but its not the best way to do things, slower, and i want to know what my stupid mistake is. anyone see it?
ive tried using
doc.RemoveChild(doc.SelectSingleNode("/a/b/c/d"
![Wink Wink](https://forums.nextpvr.com/images/smilies/wink.png)
then tried:
XmlNode node = doc.SelectSingleNode("/a/b/c"
![Wink Wink](https://forums.nextpvr.com/images/smilies/wink.png)
node.RemoveChild(node.SelectSingleNode("/d"
![Wink Wink](https://forums.nextpvr.com/images/smilies/wink.png)
so ive had to use
XmlNode baseNode = doc.SelectSingleNode("/a/b/c"
![Wink Wink](https://forums.nextpvr.com/images/smilies/wink.png)
foreach(XmlNode node in baseNode.ChildNodes){
if(node.Name == "d"
![Wink Wink](https://forums.nextpvr.com/images/smilies/wink.png)
baseNode.RemoveChild(node);
}
which works, but its not the best way to do things, slower, and i want to know what my stupid mistake is. anyone see it?