473,486 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Editing an xml string

3 New Member
Hopefully an easy question:

Using vb.net I have opened an xml file (which is encrypted) retreived the file information as a string, carry out some editing of the xml data. I now want to produce a string with the edited information so that I can pass it to a function which will encrypt and save the xml file.

I can do all of the above except for the regenerating the edited xml data into a string after it has been edited.

This is my code:

Dim xmlDoc As New XmlDocument
Dim userNodes As XmlNodeList
Dim userDetailNodes As XmlNodeList
Dim userNode As XmlNode

xmlDoc.LoadXml(xmlString)

userNodes = xmlDoc.GetElementsByTagName("User")

For Each userNode In userNodes

userDetailNodes = userNode.ChildNodes

userDetailNodes(userNameLoc).InnerText = userName

next

*********
All of the above works fine (Its only an extract to give you the basic idea)

Now I would like to pass the xml string to my function:

saveFile(xmlString)

however xmlString does not contain the updated information.

I have got around this problem by saving the xmldoc as a temp file, loading the temp file into a string and then saving it back into the encrypted file (code below) but there must be a better way of doing this???? All help appreciated!



xmlDoc.Save("C:\temp.xml")
Dim fs As New FileStream("C:\temp.xml", FileMode.Open, FileAccess.Read)
Dim sr As New StreamReader(fs)
Dim tempText As String
tempText = sr.ReadToEnd()
fs.Close()
My.Computer.FileSystem.DeleteFile("C:\temp.xml")
saveUserDetails(tempText)
Mar 26 '08 #1
0 902

Sign in to post your reply or Sign up for a free account.

Similar topics

8
524
by: Chris Dunaway | last post by:
When using a PropertyGrid, I have an object with a Date property, but I am only interested in the Time portion. How do I make the PropertyGrid allow editing the time only? Just the hours and...
0
1989
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
1
2709
by: zivon | last post by:
now for the bigger problam :) I know you pepole hate using OE for sending emails, but its user friendly and its needed in this case... I found on this forum, a code that sends email using OE...
0
1286
by: hanusoft | last post by:
This is an example of editing in DataGrid and Default Paging http://www.hanusoftware.com Html Design Code : - <asp:DataGrid id="DataGrid1" DataKeyField="id" runat="server" Height="224px"...
9
2692
by: sunita jadhav | last post by:
my question is if i type in html textbox on key press event suppose i type 12345 values in textbox then i delete or edit any value of text box suppose i edit 3 and i insert the value 6 at 3 but i...
0
7094
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
7123
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
7173
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
7305
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...
0
5427
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
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.