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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| Private Sub ExtractFileXmlXPath(ByVal fichier As String)
'Navigation et itération dans le doc XML pour la récupération des éléments "Cue"
Dim document As XPathDocument = New XPathDocument(fichier)
Dim navigator As XPathNavigator = document.CreateNavigator()
Dim nodesCue As XPathNodeIterator = navigator.Select("/MA/Sequ/Cue")
While nodesCue.MoveNext()
'Pour chaque éléments "cue", un autre navigateur permet d'extraire les infos recherchées.
If nodesCue.Current.HasChildren Then
Dim nodesNavigator As XPathNavigator = nodesCue.Current.CreateNavigator
Dim cue As String = nodesNavigator.SelectSingleNode("Number").GetAttribute("number", nodesNavigator.NamespaceURI)
If Not cue = String.Empty Then
strgBuilt.Append("cue : " & cue)
strgBuilt.AppendLine()
End If
Dim up As String = nodesNavigator.SelectSingleNode("CuePart").GetAttribute("basic_fade", nodesNavigator.NamespaceURI)
If Not up = String.Empty Then
strgBuilt.Append("up : " & up)
strgBuilt.AppendLine()
End If
Dim txt As String = nodesNavigator.SelectSingleNode("CuePart").GetAttribute("name", nodesNavigator.NamespaceURI)
If Not txt = String.Empty Then
strgBuilt.Append("TEXT : " & txt)
strgBuilt.AppendLine()
Else : txt = nodesNavigator.SelectSingleNode("InfoItems").SelectSingleNode("Info").InnerXml
If Not txt = String.Empty Then
strgBuilt.Append("TEXT : " & txt)
strgBuilt.AppendLine()
End If
End If
'Même principe pour les noeuds aux enfants multiples.
Dim nodesCueDatas As XPathNodeIterator = nodesCue.Current.SelectDescendants("CueData", nodesNavigator.NamespaceURI, False)
While nodesCueDatas.MoveNext()
If nodesCueDatas.Current.HasChildren Then
Dim nodesCueDatasNavigator As XPathNavigator = nodesCueDatas.Current.CreateNavigator
Dim chan As String = nodesCueDatasNavigator.SelectSingleNode("Channel").GetAttribute("channel_id", nodesNavigator.NamespaceURI)
If Not chan = String.Empty Then
strgBuilt.Append("chan : " & chan)
End If
Dim valeur As String = nodesCueDatasNavigator.SelectSingleNode("Value").InnerXml
If Not valeur = String.Empty Then
strgBuilt.Append(" valeur : " & valeur)
strgBuilt.AppendLine()
End If
End If
End While
strgBuilt.AppendLine()
End If
End While
SaveToFile(txtFilePath)
End Sub |