Option
Explicit
Private
Sub
TestIt()
Dim
Meldung
As
Variant
Meldung = GetXmlNode(
"C:\Temp\Forumtest.xml"
, _
"eintrag"
,
"Nachname"
,
"Stefan"
,
"Telefonnummer"
)
MsgBox Meldung
End
Sub
Private
Function
GetXmlNode( _
ByVal
Dateipfad
As
String
, _
ByVal
Kategorie
As
String
, _
ByVal
SucheNach
As
String
, _
ByVal
SucheWert
As
String
, _
ByVal
FindeWert
As
String
)
As
Variant
Dim
xmlDatei
As
DOMDocument
Dim
oListe
As
IXMLDOMNodeList
Dim
oKnoten
As
IXMLDOMNode
Set
xmlDatei =
New
DOMDocument
xmlDatei.Load Dateipfad
Set
oListe = xmlDatei.DocumentElement.SelectNodes(Kategorie)
For
Each
oKnoten
In
oListe
If
oKnoten.SelectSingleNode(SucheNach).Text = SucheWert
Then
GetXmlNode = oKnoten.SelectSingleNode(FindeWert).Text
Exit
For
End
If
Next
End
Function