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"
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") //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"
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?