Option
Explicit
Private
Sub
Bsp()
Dim
xmlNode
As
MSXML2.IXMLDOMNode
Dim
strFilename
As
String
Dim
strMyXPath
As
String
strFilename =
"D:\example.xml"
With
New
MSXML2.DOMDocument60
.async =
False
.validateOnParse =
True
Call
.setProperty(
"SelectionLanguage"
,
"XPath"
)
If
Not
.Load(strFilename)
Then
With
.parseError
Call
Err.Raise(.ErrorCode, , .srcText & vbNewLine & vbNewLine & .reason)
End
With
End
If
strMyXPath =
"/telefonliste/datensatz[name='Tommy']/telefon"
Set
xmlNode = .SelectSingleNode(strMyXPath)
If
Not
xmlNode
Is
Nothing
Then
Call
MsgBox(strMyXPath &
" = '"
& xmlNode.Text &
"'"
, vbInformation)
Else
Call
MsgBox(
"'"
& strMyXPath &
"' ergab kein Ergebnis."
, vbExclamation)
End
If
End
With
End
Sub