Solved

Updating a single attribute element in an XML file

Posted on 2006-11-04
2
159 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

895 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

12 Experts available now in Live!

Get 1:1 Help Now