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
| Option Explicit
Public Sub AccessNode()
Dim MyXml As New MSXML2.DOMDocument
Dim Noeuds As IXMLDOMNodeList
Dim NoeudCible As IXMLDOMNode
Dim Noeud As IXMLDOMElement
Dim Attributs As IXMLDOMNamedNodeMap 'Collection
Dim A As IXMLDOMAttribute 'Pour boucler sur la collection
Dim vOut As String
With MyXml
If Not .LoadXML(Replace(Range("a1").Value(xlRangeValueXMLSpreadsheet), "ss:Data", "Data")) Then Err.Raise .parseError.ErrorCode, , .parseError.reason
'accès au Noeud :
'<Workbook>
'<Styles>
'<Style>
Set NoeudCible = .SelectSingleNode("/Workbook/Styles/Style")
If Not NoeudCible Is Nothing Then
Set Noeuds = NoeudCible.SelectNodes("Font")
For Each Noeud In Noeuds
Set Attributs = Noeud.Attributes
For Each A In Attributs
vOut = Noeud.getAttribute(A.Name)
Debug.Print A.Name & " " & vOut
Next
Next
End If
End With
Set NoeudCible = Nothing
Set Attributs = Nothing
Set Noeud = Nothing
Set MyXml = Nothing
End Sub |
Partager