[quoted text, click to view] Billg_sd wrote:
[quoted text, click to view] > <Parameters>
> <Parameter>123</Parameter>
> <Parameter>456</Parameter>
> </Parameters>
>
> How do I find Parameter=123 and delete it?
Dim Xml_Document As XmlDocument = New XmlDocument
Xml_Document.PreserveWhitespace = True
Xml_Document.Load(Args(0))
Dim Parameter As XmlNode =
Xml_Document.SelectSingleNode("Parameters/Parameter[. = 123]")
If Not Parameter Is Nothing Then
Parameter.ParentNode.RemoveChild(Parameter)
End If
Xml_Document.Save(Console.Out)
Of course instead of doing Save(Console.Out) you could also save to some
file.
[quoted text, click to view] > How do I delete all children of <Parameters>?
Dim Xml_Document As XmlDocument = New XmlDocument
Xml_Document.PreserveWhitespace = True
Xml_Document.Load(Args(0))
Dim Parameters As XmlNodeList =
Xml_Document.SelectNodes("Parameters/node()")
For Each Child As XmlNode In Parameters
Child.ParentNode.RemoveChild(Child)
Next
Xml_Document.Save(Console.Out)
[quoted text, click to view] > Assume I read this XML in from a file and wish to write the results of my
> changes out to a different file. Is this simpler to do in .Net 2.0 than in
> .Net 1.5?
There is no .NET 1.5, but saving to a file is as simple as
Xml_Document.Save("file.xml")
whether you use .NET 1.x or .NET 2.0.
There haven't been any major changes in System.Xml or
System.Xml.XmlDocument when it comes to loading and saving.
--
Martin Honnen --- MVP XML