innerhtml

时间:2018-06-15 13:41:59

标签: php getattribute

有没有办法通过PHP中的getAttribute选择innerHTML。 我已经尝试了这个但是它没有工作:

$fetchresult[] = array($link->getAttribute("innerhtml"), $link->nodeValue);

当我的var_dump $link这是输出:

object(DOMElement)#7 (18) { ["tagName"]=> string(3) "div" 
["schemaTypeInfo"]=> NULL ["nodeName"]=> string(3) "div" ["nodeValue"]=> 
string(24) "TEXT" ["nodeType"]=> int(1) ["parentNode"]=> 
string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object 
value omitted)" ["firstChild"]=> string(22) "(object value omitted)" 
["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> NULL 
["nextSibling"]=> NULL ["attributes"]=> string(22) "(object value omitted)" 
["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> 
NULL ["prefix"]=> string(0) "" ["localName"]=> string(3) "div" ["baseURI"]=> NULL 
["textContent"]=> string(24) "TEXT" }

提前致谢

1 个答案:

答案 0 :(得分:0)

exports.tempFunction = (req, res) => { // Example input: {"message": "Hello!"} const Compute = require(`@google-cloud/compute`); const compute = new Compute(); const zone = compute.zone('us-central1-a'); const disk = zone.disk('disk1'); const config = { sourceSnapshot: "projects/{YOUR-PROJECT}/global/snapshots/{YOUR_SNAPSHOT}" }; disk.create(config, function(err, disk, operation, apiResponse) { // `disk` is a Disk object. // `operation` is an Operation object that can be used to check the // status of the request. console.log(err); console.log(disk); console.log(operation); console.log(apiResponse); res.status(200).send("success"); }); };不是属性,它是一个非标准的DOM扩展,它将元素的子节点序列化(当用作getter时)为HTML字符串。

完全从阅读PHP手册开始,相应的似乎是:

  1. 在变量(innerHTML);
  2. 中创建一个空字符串
  3. 循环childNodes
  4. 将该节点的HTML附加到变量($html = ""