|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Deleting Values from an XML node?Why is it that when I attempt to delete all values from a node in an XML file using the code below, I end up with the values being deleted, but not the tags? The code i have is: Dim CountryCodeValueNodes As XmlNodeList Dim CountryCodeValue As XmlNode CountryCodeValueNodes = configurationFile.SelectNodes("//type[@name='lstCountry']/values/value") For Each CountryCodeValue In CountryCodeValueNodes Dim CountryCode = CountryCodeValue.Attributes("key") 'Remove all values CountryCodeValue.Attributes.RemoveAll() Next The original values in the file I am trying to write are as follows: <type name="lstCountry" default="" inherits="combo" regex="" regexsample=""> <values> <value key="US"> </value> <value key="AD"> </value> <value key="AE"> </value> <value key="AF"> </value> <value key="AG"> </value> <value key="AI"> </value> </values> </type> What I actually get as the result is: <type name="lstCountry" default="" inherits="combo" regex="" regexsample=""> <values> <value> </value> <value> </value> <value> </value> <value> </value> <value> </value> <value> </value> </values> </type> Thanks MA Major Aardvark schrieb:
Show quoteHide quote > Hi Hiddeldiho,> > Why is it that when I attempt to delete all values from a node in an XML > file using the code below, I end up with the values being deleted, but not > the tags? > > The code i have is: > > Dim CountryCodeValueNodes As XmlNodeList > Dim CountryCodeValue As XmlNode > CountryCodeValueNodes = > configurationFile.SelectNodes("//type[@name='lstCountry']/values/value") > For Each CountryCodeValue In CountryCodeValueNodes > Dim CountryCode = CountryCodeValue.Attributes("key") > 'Remove all values > CountryCodeValue.Attributes.RemoveAll() > Next > With this line "CountryCodeValue.Attributes.RemoveAll()" you are removing all *Attributes*, not the nodes. Try CountryCodeValue.RemoveAll()
How Can I Do This?
DDE - is it available in .NET? Subclassing Disposing of Windows Forms GetChildRows error - what the f@&# ! Printing XML Formatted Report in Windows Application Get machine user & password logon Printer Ink Status VB6 query format for comparing number value Prevent Date Enter before Current date |
|||||||||||||||||||||||