473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Deleting Values from an XML node?

Hi

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
Nov 3 '06 #1
1 1098

Major Aardvark schrieb:
Hi

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
Hiddeldiho,
With this line "CountryCodeValue.Attributes.RemoveAll()" you are
removing all *Attributes*, not the nodes. Try
CountryCodeValue.RemoveAll()

Nov 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: A | last post by:
Hi, I'm trying to solve the 3rd and final case in deleting a node from a binary tree. That is, deleting a node that has two subtrees. If someone out there who knows about this problem as they...
0
by: indo3 | last post by:
Hello, I program an xml editor with xerces for the university of Braunschweig, the user dont see any xml tags, it is represented in a JTree. Now the user shall be able to insert nodes, which...
1
by: Sumeeta. | last post by:
Hi, Am new to xml, using the xercess c++ DOM parser . I want to delete a node from the xml file. Have used th removeChild() method...but nothin happens.. not even errors.. it executes but...
5
by: Olaf Gschweng | last post by:
We're new into DB2 and have some problem with DB2 8.1 (?) on a Linux system. We load some big tables of a DB2 database from files every day. We do a "DELETE FROM table" for each table and then we...
2
by: melanieab | last post by:
Hi, I'm deleting nodes in my xml file, and it does seem to work, but then when I later reload the file and make an xmlNodeList, the nodelist count still includes the deleted nodes yet the file...
1
by: tsuki | last post by:
Hello, I have a problem concerning DOM and XML. The structure of my xml is the following: <?xml version="1.0" encoding="utf-8"?> <website> <language1> <seite> <bereich1>
2
by: riceyeh | last post by:
Hi, What does <xsl:if test="not($values)"mean? What I do not understand is $values? Here, means array? And . = $value means current node is equal to the variable value? So the total meaning is...
1
by: tina chatterjee | last post by:
i have implemented binary tree insertion and deletion using my on coding. but it was not a tough job till i got confused while deleting a node having both left and right child.I am unable to...
5
bluechimera
by: bluechimera | last post by:
Of course this isn't the whole program.... but it is a rather large slice of code. Yes I am in college, I am not asking for someone to do this for me.. I think that is rather stupid... you don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.