[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Append to xml file

Posted on 2012-04-12
3
Medium Priority
?
320 Views
Last Modified: 2012-04-12
Is there a way to read an XML file and then "append" a line to it with vb code?

Example...on a button click event, could I add this
<add key="strCon" value="user id=lrbrister;pwd=mypassword;data source=lrbrister_dell\;initial catalog=mydatabaser"/>


To this mysettings.config file
<appSettings>
  <add key="KeyToOverride" value="Overridden" />
  <add key="KeyToBeAdded" value="EntirelyNew" />
</appSettings>

So that the file would now look like this
<appSettings>
  <add key="KeyToOverride" value="Overridden" />
  <add key="KeyToBeAdded" value="EntirelyNew" />
  <add key="strCon" value="user id=lrbrister;pwd=mypassword;data source=lrbrister_dell\;initial catalog=mydatabaser"/>
</appSettings>
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

by:binaryevo
ID: 37837644
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 2000 total points
ID: 37838451
Try
Dim XReader = XElement.Load(New System.IO.StreamReader("YourXMLFile"))
XReader.Element("appSettings").Add(<add key="strCon" value="user id=lrbrister;pwd=mypassword;data source=lrbrister_dell\;initial catalog=mydatabaser"/>)
XReader.Save("YourXMLFile")

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 37838658
Bewst "clean" answer
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question