1
如何选择Stage One div中的文本。它有一个独特的名称“field-name-field-stage-one”。我想回应总结。XPath类选择器
链接至网站:http://fosterinnovationculture.com/drupalc/?q=node/17
这是我到目前为止有:
$doc = new DomDocument;
$some_link = 'http://fosterinnovationculture.com/drupalc/?q=node/17';
$tagName = 'div';
$attrName = 'class';
$attrValue = 'field-name-field-stage-one';
$doc->validateOnParse = true;
$doc->loadHtml(file_get_contents($some_link));
$xpath = new DOMXpath($doc);
$elements = $xpath->query("/html/body//div[contains(@class,'$attrValue')]");
现在,如果我想将文本存储在变量中,就像'$ stage = $ elements [0] - > nodeValue;'? – marcos
@marcos yup,适合我。 – alecxe