如何选择Stage One div内的文本。它有一个唯一的名称" field-name-field-stage-one"。我想回应一下总结。
网站链接: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')]");
答案 0 :(得分:0)
获取带有field-item
类的内部元素并提取nodeValue
值:
$elements = $xpath->query("/html/body//div[contains(@class,'$attrValue')]/div[contains(@class, 'field-item')]");
print_r($elements[0]->nodeValue);
打印:
The survey results show that your organization is ‘interested’ in design-led innovation, which is stage 1 in our framework.
‘Interested’ means that some people in the organization are noticing design contributions and the methods designers use. Some individuals are experiencing success in a few projects. The use of design methods is ad hoc, unintentional and happening at a grass roots level. Design continues to be perceived as an added cost to the development process. As a result, there is little executive support or buy-in.