Jump to content

How to get the content of html tag

Recommended Posts

So I already have the DOM element in an object and what I am trying to do is getting the 173 out of this $tagElement

<span class="health-count">173</span>

I tried $tagElement.innnerHTML and innerText but it didnt work.

Sorry if its a dumb question, but I have spent some time on this and could not find anything on the forum.

Link to post
Share on other sites

maybe StringMid or _StringBetween?

$string = '<span class="health-count">173</span>'
$start=StringInStr($string,'<span class="health-count">')+StringLen('<span class="health-count">')
$restul = StringMid($string,$start,$end-$start)


#include <String.au3>
$test = _StringBetween($string,'<span class="health-count">','</span>',0)
if IsArray($test) then ConsoleWrite('$test[0]='&$test[0]&@CRLF)


Link to post
Share on other sites

@Kinhow : show your code. There is probably and error with the $tagElement object.

This works :

#Include <IE.au3>

$oIE = _IECreate()

_IEBodyWriteHTML($oIE, '<span class="health-count">173</span>')

$oSpans = _IETagNameGetCollection($oIE, "span")
For $oSpan In $oSpans
    If $oSpan.className = "health-count" Then MsgBox(0, "", $oSpan.innerHtml & @CRLF)


Link to post
Share on other sites
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...