Re: Deleting element from xml doc

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

.



Relevant Pages

  • Re: Separating presentation from data layer
    ... Cor... ... > the time reading. ... you can just ask in the creation of that if a datasource is ... > nothing and than do all handling to get the data again. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem getting nested data
    ... Cor ... > from XML Schema ". ... > Richard Rosenheim ... >> the XML file. ...
    (microsoft.public.dotnet.general)
  • Re: XML and the Datagrid
    ... Cor and Everyone, ... In your experience then what good is XML, ... single XML file) and as a means to transporting data. ... > Hi Dan, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: XML Writing and Reading
    ... All done Cor. ... I can now save a layout to xml and open a layout from xml. ... you mentioned the colors and font are a little trickier. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Updating Dataset from XML
    ... Have a good one Cor, ... >> thought that maybe I could use that to load my XML ... and how it handles updates to the target database. ... >> Maybe I'll just have to resort to a good old loop... ...
    (microsoft.public.dotnet.framework.adonet)