DOMNode无法转换为字符串

时间:2011-11-27 23:05:32

标签: php html parsing dom screen-scraping

<?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

1 个答案:

答案 0 :(得分:1)

查看此页面中的示例

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

使用

$album->nodeValue