-
Get line # from xml file
Hello:
I have no idea if I'm on the right track here (probably not).
I want to get the last line number containing a value of "_Toc" from an xml file, and then use this as my starting point to read data using VS 2017.
Code:
Using reader As XmlReader = XmlReader.Create(txtOpenXML.Text)
While reader.Read()
' Get last line # containing "_Toc"
Dim xml = XDocument.Load(txtOpenXML.Text, LoadOptions.SetLineInfo)
Dim lineNumbers = xml.Descendants().Where(Function(x) x.Value.Contains("_Toc")).Cast(Of IXmlLineInfo)().[Select](Function(x) x.LineNumber)
For Each lineNumber In lineNumbers
MessageBox.Show(lineNumber.ToString)
Next
I do not even know if this is the best approach. Ultimately, I will read all the "w:t" lines starting at line ###, which I have coded already, except for using the line number as a starting point.
Thank you!