-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConvertXmlToListOfStrings.vb
35 lines (29 loc) · 1.2 KB
/
ConvertXmlToListOfStrings.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Private Shared Function ConvertXmlToList(fileName) As IEnumerable(Of String)
Dim list As New List(Of String)
Dim recordValue As Boolean = False
Dim value As String = ""
Dim settings As New XmlReaderSettings With {.DtdProcessing = DtdProcessing.Parse}
Using reader As XmlReader = XmlReader.Create(fileName, settings)
reader.MoveToContent()
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
Select Case reader.Name
Case "w:p"
recordValue = True
End Select
Case XmlNodeType.Text
If recordValue Then
value &= reader.Value
End If
Case XmlNodeType.EndElement
If reader.Name = "w:p" Then
recordValue = False
list.Add(value)
value = ""
End If
End Select
End While
End Using
Return list
End Function