Menu

#66 Role attribute

Unassigned
closed
None
2022-04-09
2019-11-24
No

I am trying to parse on <span role="heading" using:

 foreach($html->find("span[role=heading]") as $role) {
                                echo 'Inner' . $role->innertext . '<br>' . PHP_EOL;

What am I missing?

I can perform typical parses, such as:

foreach($html->find('ul.Experiences') as $ul) {
                foreach($ul->find('li.experience') as $li)
                    echo $li->innertext . '<br>' . PHP_EOL;

Discussion

  • LogMANOriginal

    LogMANOriginal - 2019-12-01

    Your code looks fine to me. I can't seem to reproduce your issue.

    Which version do you use?
    Can you share a document that consistently fails for you?

    Here is my test script for reference (tested with 1.9):

    <?php
    
    include_once 'simple_html_dom.php';
    
    $doc = <<<HTML
    <div>
    <span role="heading">Hello, World!</span>
    </div>
    HTML;
    
    $dom = str_get_html($doc);
    
    foreach ($dom->find('span[role=heading]') as $role) {
        echo $role->innertext . PHP_EOL;
    }
    
     
  • LogMANOriginal

    LogMANOriginal - 2022-04-09
    • status: open --> closed
    • assigned_to: LogMANOriginal
     

Log in to post a comment.