troubleshooting Question

File text replace

Avatar of jdhackett
jdhackettFlag for Ireland asked on
Visual Basic Classic.NET ProgrammingVisual Basic.NET
7 Comments1 Solution170 ViewsLast Modified:
Hi
I have code below which replaces some text in a file.
However, I wish to replace
        </Address>
        <Address>
with "". But only if they're one after the other. How would I run a replace if the text if on two lines?
Dim Fs As FileStream = New FileStream(stXML_File, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
         Dim sw As New StreamWriter(Fs)
         Dim sr As New StreamReader(Fs)
         Dim str As String
         str = sr.ReadToEnd()
 
         str = str.Replace("GIT_RiskPremiumBreakdown", "RiskPremiumBreakdown")
         str = str.Replace("PL_RiskPremiumBreakdown", "RiskPremiumBreakdown")
         str = str.Replace("CAR_RiskPremiumBreakdown", "RiskPremiumBreakdown")
         str = str.Replace("<NewDataSet xmlns", "<!--NewDataSet xmlns")
         str = str.Replace("<ESPolicyTransmission", "--><ESPolicyTransmission")
 
         str = str.Replace("</NewDataSet>", "")
 
         Fs.Position = 0
         Fs.SetLength(str.Length)
 
         sw.Write(str)
         sw.Flush()
         sw.Close()
         Fs.Close()
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros