changing data in an xml tag

daveofgv

Well-known member
Joined
Sep 17, 2008
Messages
218
Location
Dallas, TX
Programming Experience
1-3
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:

VB.NET:
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
 
Currently, I am using the following for multiple files. Is there something easier since I have about 1000 files?

VB.NET:
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
 
Back
Top