How to imitate child selector with Simple HTML DOM?

后端 未结 2 368
粉色の甜心
粉色の甜心 2021-01-23 09:03

Fellas!

I have one nasty page to parse but can\'t figure out how to extract correct data blocks from it using Simple HTML DOM, because it has no CSS child selector suppo

2条回答
  •  情歌与酒
    2021-01-23 09:57

    Simple example with php DOM:

    $dom = new DomDocument;
    $dom->loadHtml('
    
    • a
    • b
      • c
    '); $xpath = new DomXpath($dom); foreach ($xpath->query('//ul[@class="ul-block"]/li') as $liNode) { echo $liNode->nodeValue, '
    '; }

提交回复
热议问题