【问题标题】:DOMNode could not be converted into a stringDOMNode 无法转换为字符串
【发布时间】:2012-01-07 13:22:36
【问题描述】:
<?php
// try this html listing example for all nodes / includes a few getElementsByTagName options:

$file = $DOCUMENT_ROOT. "http://website.com";
$doc = new DOMDocument();
@$doc->loadHTMLFile($file);

// example 1:
$elements = $doc->getElementsByTagName('tr');

$album = $elements->item(1);

echo $album;

如何将其转换为可以输出到屏幕的数据?它说我无法转换为字符串。我读过DOMnode 的功能不像数组,但它会产生DOMNodeList

【问题讨论】:

    标签: php html parsing dom screen-scraping


    【解决方案1】:

    查看此页面中的示例

    http://www.php.net/manual/en/domnodelist.item.php

    使用

    $album->nodeValue
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 2018-02-19
      • 2018-06-15
      • 2016-03-11
      • 2012-05-12
      相关资源
      最近更新 更多