473,402 Members | 2,064 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,402 software developers and data experts.

Write an XML node

Hi

I have read in an single node and it's list of values into a CheckedListBox
so that I can select which values I actually want to have in the node.

The question I now have is how can I write just this one node and its values
back to the original XML file, replacing the data that is already there?

Thanks for any suggestions you have!
Nov 1 '06 #1
1 1997
Here's a quick example that might get you started. For starters prepare
the following xml document using notepad (or whatever) and save it on
your desktop as test.XML

<BaseNode>
<TargetNode>ChangeMe</TargetNode>
<TargetNode>DontChangeMe</TargetNode>
</BaseNode>

Ok, then here's the code I wrote real quick to look for a specific node
and change it's value.

Imports System.Xml

Module Module1

Sub Main()
' Change the below to match the file's directory
Dim dir As String = "C:\Documents and
Settings\username\Desktop\test.XML"
Dim doc As New XmlDocument
doc.Load(dir)
Dim nodelist As XmlNodeList =
doc.GetElementsByTagName("TargetNode")
For Each node As XmlNode In nodelist
If node.InnerText = "ChangeMe" Then
node.InnerText = "OKIwill"
End If
Next
doc.Save(dir)
End Sub

End Module

Hope that helps!

Thanks,

Seth Rowe
Major Aardvark wrote:
Hi

I have read in an single node and it's list of values into a CheckedListBox
so that I can select which values I actually want to have in the node.

The question I now have is how can I write just this one node and its values
back to the original XML file, replacing the data that is already there?

Thanks for any suggestions you have!
Nov 1 '06 #2

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
6
by: ok | last post by:
<img src="http://www.6park.com/enter2/av.gif" onload="document.write('an iframe obj');"> First of all, it destroy the HTML page. Secondly even if it does not destroy it, the iframe object will...
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
4
by: Jeff smith | last post by:
I am reading the value from config file using the below statement. System.Configuration.ConfigurationSettings.AppSettings("MY_DATA") How to write data back to the same location? I am using...
7
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one...
1
by: kelvin273 | last post by:
hello, i've an xml file and i want to transform it to another one with only certain attribute in certain nodes (!) for example, all the node have id, title and description are attributes. but i...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
5
by: remlostime | last post by:
struct nodeType { int v, index; }; list<nodeTypenode; for(list<nodeType>::iter = node].begin(); iter != node].end(); iter++) What's wrong with it? how can i fix it?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.