$sHTML = _
'<body>' & @CRLF & _
' <span id="users" class="users">' & @CRLF & _
' <div id="user">User1</div>' & @CRLF & _
' <div id="user" class="user">User2</div>' & @CRLF & _
' <div id="user" class="user">User3</div>' & @CRLF & _
' </span>' & @CRLF & _
' <span id="logins" class="logins">' & @CRLF & _
' <div id="login">login1</div>' & @CRLF & _
' <div id="login">login2</div>' & @CRLF & _
' <div id="login">login3</div>' & @CRLF & _
' </span>' & @CRLF & _
'</body>'
$sXPath = '*/span[(@id="users" or @class="users")]/div[@id="user"][1]'
$oNode = _XHtmlXPath_SelectNode($sHTML, $sXPath)
ConsoleWrite(_XHtmlXPath_GetNodeValue($oNode) & @LF)
Func _XHtmlXPath_SelectNode($sXHTML, $sXPath)
Local $oXMLDOM = ObjCreate('Msxml2.DOMDocument.3.0')
If Not IsObj($oXMLDOM) Then
Return SetError(1, 0, 0)
EndIf
$oXMLDOM.loadXML($sXHTML)
Return $oXMLDOM.selectSingleNode($sXPath)
EndFunc
Func _XHtmlXPath_GetNodeValue($oNode, $sValue = 'Text')
If Not IsObj($oNode) Then
Return SetError(1, 0, 0)
EndIf
If $sValue = 'Text' Then
Return $oNode.Text
EndIf
Return $oNode.Xml
EndFunc