Re: Deleting element from xml doc
- From: Marc Gravell <marc.gravell@xxxxxxxxx>
- Date: Sun, 21 Oct 2007 03:13:40 -0700
If you first convert that set to an XML dataset.
Sorry, Cor - but personally I think that a DataSet is entirely the
wrong tool for handling xml... just my opinion...
the following seems to more closely express the intent:
XmlDocument doc = new XmlDocument();
doc.Load("path.xml");
foreach (XmlNode node in doc.SelectNodes("/Collection/
Book[@Locator='Yes']")) {
node.ParentNode.RemoveChild(node);
}
doc.Save("path2.xml");
The arg to SelectNodes reads "find all root->Collection->Book elements
where there is a Locator attribute with the value of yes"; we iterate
that, for each one removing it from it's parent.
Marc
.
- References:
- Re: Deleting element from xml doc
- From: Cor Ligthert[MVP]
- Re: Deleting element from xml doc
- From: Gaurav
- Re: Deleting element from xml doc
- From: Cor Ligthert[MVP]
- Re: Deleting element from xml doc
- Prev by Date: Re: Scanning hard drive
- Next by Date: Re: Deleting element from xml doc
- Previous by thread: Re: Deleting element from xml doc
- Next by thread: Re: Deleting element from xml doc
- Index(es):
Relevant Pages
|