开发者

Find and replace a text in XML using VB.net

I have a XML file. Inside t开发者_开发百科he XML file where ever I find the string as ("C:\Results\test1_01") I need to replace it with ("B:\final\test1_01") and save it. Please guide me for this.

Thanks in advance,


       Try
            Dim fOut as StreamWriter = New StreamWriter("Output.xls")
            Using sr As StreamReader = New StreamReader("YourXMLFile.xml")
                Dim line As String
                Do
                  line = sr.ReadLine()
                fOut.WriteLine(Line.Replace("C:\Results\test1_01","B:\final\test1_01"))
                Loop Until line Is Nothing
                sr.Close()
                fOut.Close()
            End Using
        Catch E As Exception
            ' Let the user know what went wrong.
            Console.WriteLine("The file could not be read:")
            Console.WriteLine(E.Message)
        End Try
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜