Questa domanda sembra avere avuto risposta numerose volte ma non riesco ancora a mettere insieme i pezzi.Ottieni tutti gli elementi per nome della classe utilizzando DOMDocument
Vorrei ottenere il valore del nodo di ogni classe per nome. per esempio
<td class="thename"><strong>32</strong></td>
<td class="thename"><strong>12</strong></td>
vorrei afferrare il 32 e il 12. assumo questo richiede per tipo di ciclo for ma non sicuro esattamente come procedere attuazione. Ecco cosa ho fino ad ora
$domain = "http://domain.com";
$dom = new DOMDocument();
$dom->loadHTMLFile($domain);
$xpath = new DomXpath($dom);
$div = $xpath->query('//*[@class="thename"]')->item(0);
$stuff = $div ->textContent;
echo($stuff);
che sembra fare il trucco. puoi abbattere la query xpath. Questo è tutto nuovo per me. grazie – Sammy
Io uso [XPath 1.0] (http://cweiske.de/tagebuch/XPath%3A%20Select%20element%20by%20class.htm), non fa differenza. Puoi usare la tua varianza '$ query = '// * [@ class ="'. $ ClassName. '"]';' – user2112300
$ img_tags = $ tags-> query ("// * [contiene (concat ('' , normalize-space (@class), ''), 'thumbBlock')]/div/div/a/img "); questo mi dà 500 errori interni del server – Luckyy