Results 1 to 2 of 2

Thread: changing data in an xml tag

  1. #1
    daveofgv is offline VB.NET Forum Genius
    .NET Framework
    .NET 3.5
    Join Date
    Sep 2008
    Location
    Dallas, TX
    Posts
    195
    Reputation
    92

    changing data in an xml tag

    hello all -

    I have the below code that can change the data in one XML tag. This is what I want, however, I want it to change all the XML's in a complete directory:

    Code:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim MyXML As New XmlDocument()
    
            MyXML.Load("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Equipments.xml")
    
    
            Dim MyXMLNode As XmlNode = MyXML.SelectSingleNode("Documents/Document/Invoice/Supplier/Number")
    
    
            If MyXMLNode IsNot Nothing Then
    
    
                MyXMLNode.ChildNodes(0).InnerText = ("hello")
    
    
            Else
    
    
                'Do whatever 
    
    
            End If ' Save the Xml.
    
            MyXML.Save("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_EquipmentLog2.xml")
    
        End Sub
    Currently, I can only do one XML at a time - I need it to recursive through all XMLs in one directory and subfolders.

    Is this a quick change?

    thanks in advanced.

    daveofgv

  2. #2
    daveofgv is offline VB.NET Forum Genius
    .NET Framework
    .NET 3.5
    Join Date
    Sep 2008
    Location
    Dallas, TX
    Posts
    195
    Reputation
    92
    Currently, I am using the following for multiple files. Is there something easier since I have about 1000 files?

    Code:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim MyXML As New XmlDocument()
    
            MyXML.Load("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Equipments.xml")
            MyXML.Load("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Receipts.xml")
            MyXML.Load("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Funds.xml")
    
            Dim MyXMLNode As XmlNode = MyXML.SelectSingleNode("Documents/Document/Invoice/Supplier/Number")
    
    
            If MyXMLNode IsNot Nothing Then
    
    
                MyXMLNode.ChildNodes(0).InnerText = ("hello")
    
    
            Else
    
    
                'Do whatever 
    
    
            End If ' Save the Xml.
    
                    MyXML.Save("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Equipments.xml")
                    MyXML.Save("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Receipts.xml")
                    MyXML.Save("C:\Users\mycomputer\Desktop\New folder (3)\54_80199366_345614993\80199366_345614993_Funds.xml")
    
        End Sub

Bookmarks

Posting Permissions

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