If the file is XML, you should use XML/XPath:
Code:
' Imports System.Xml
' Imports System.Xml.XPath
Dim Document As New XmlDocument()
Document.Load(FileName)
' Find all the text between <x>...</x> tags
Dim Nodes As XmlNodeList = Document.SelectNodes("//x")
For Each Node As XmlNode In Nodes
Console.WriteLine(Node.InnerText)
Next
For unstructured text, use regular expressions:
Code:
' Imports System.IO
' Imports System.Text.RegularExpressions
Dim StartText As String = "<x>"
Dim EndText As String = "</x>"
Dim Text As String
Using sr As StreamReader = File.OpenText(FileName)
Text = sr.ReadToEnd
End Using
Dim Pattern As String = StartText & "(.+)" & EndText
Dim Matches As MatchCollection = Regex.Matches(Text, Pattern)
For Each m As Match In Matches
Console.WriteLine(m.Groups(1).Value)
Next
Bookmarks