2011-06-22 48 views
0

我有一個XML文件。在XML文件中,我找到了字符串(「C:\ Results \ test1_01」),我需要用(「B:\ final \ test1_01」)替換它並保存。請爲我指導。使用VB.net查找並替換XML中的文本

由於提前,

+2

你的問題表明,已完成的任何工作或研究。但是,你的答案是。 – Ahmad

回答

2
 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