Results 1 to 3 of 3

Thread: updating records in xml file

  1. #1

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    updating records in xml file

    I need to load an xml file using vb.net, and replace some values with whatever I need too. Then save this xml file again for further use.

    Any tutorial or point in the right direction would be awsome!

    Thanks!!

  2. #2
    Addicted Member
    Join Date
    Aug 2003
    Posts
    153
    I recommend the use of XPaths to navigate thru the document to update certain record, and use the XmlDocument class a representation of the document.

    Plenty of info via Google and MSDN on these.

  3. #3

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    Great! I figured out though...

    how to load the xml document, and I can change Items in the xml as long as i know the index of the item. Using this...

    Code:
    Private Sub xmlChange()
    
            Dim DS As New DataSet()
    
            DS.ReadXml("c:\inetpub\wwwroot\xmlTest\xmlemp.xml")
    
            DS.Tables(0).Rows(1).Item("Name") = "VALUE TO REPLACE WITH"
    
           DS.WriteXml("c:\inetpub\wwwroot\xmlTest\xmlemp.xml")
    
    End Sub
    Now how can I have it search that Dataset for a particular string, and then change the value of that string? For example:

    In my xml, i will have keywords such as %@Prospects% and %@Name% that I want to replace with values, but now can I tell the vb to search for those values instead of me having to know where they are beforehand?

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width