Solved

Updating a single attribute element in an XML file

Posted on 2006-11-04
2
158 Views
Last Modified: 2013-11-19
Hi there, given the below xml file

how can I amend xxxxx?

<?xml version="1.0" encoding="utf-8" ?>
<values>
      <setting attribute = "user_last_logged_on" value="xxxxx"></setting>
</values>
0
Comment
Question by:DavidGreenfield
2 Comments
 

Author Comment

by:DavidGreenfield
ID: 17874681
I have changed the xml format to :

<?xml version="1.0" encoding="utf-8" ?>
<values>
      <setting attribute = "user_last_logged_on">
            <user>xxxxx</user>
      </setting>
</values>

and the code so far is:

        Dim persist_xml_nodelist As XmlNodeList
        Dim persist_xml_doc = New XmlDocument()
        Dim persist_xml_node As XmlNode

        persist_xml_doc.Load("persisted.xml")
        persist_xml_nodelist = persist_xml_doc.SelectNodes("/values/setting[@attribute='user_last_logged_on']/user")
        For Each persist_xml_node In persist_xml_nodelist
            persist_xml_node.InnerText = cbo_Username.Text
        Next
        persist_xml_doc.Save("persisted.xml")
        Debug.Print(persist_xml_doc.InnerXml())

the debug print shows the xml updated correctly.  But the xml when I go to view it - it hasn't changed.  So something seems to be going wrong on saving :oS

Thanks in advance
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 500 total points
ID: 17875979
Maybe the persisted.xml is opened or is readonly .... try deleting this file and use the save method with a full path to the file like ("C:\Persisted.xml")
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now