问题描述
我正在使用循环来填充一个名为$ list的数组。它的工作就像一个魅力。
I am using a loop to populate an array called $list. it is working like a charm..
// $content is a DOMNodeList Object
// $value is a DOMElement Object
$list = array();
foreach ($content as $value){
array_push($list, 'title'=>$value->nodeValue);
}
事件我的循环正好填充我的数组,我想去挖掘这个DOM的东西多一点,以了解更好的东西(这个DOM的东西是给我新的...)。所以我想要的是看看如何在$ code> DOMNodeList Object($ content)和 DOMElement Object($ value)
看起来像。
Eventhough my loop is populating my array correctly, I would like to digg into that DOM thing a little more to understand things better (this DOM thing is to new to me...). So what I would like, is to see how the DOMNodeList Object ($content)
and DOMElement Object ($value)
looks like.
所以我的问题很简单:我如何回声那些元素?
So my question is simple: how can I "echo-out" those 'elements'?
推荐答案
比echo-outDomElement更好,阅读文档:。
Better than "echo-out" DomElement, read the documentation: http://php.net/manual/en/class.domelement.php.
如果要查看XML表示,请使用,
ie
If you want to see XML representation, use http://www.php.net/manual/en/domnode.c14n.php,i.e.
echo $value->c14N(false,true);
这篇关于如何回显一个DOMNodeList对象和一个DOMElement对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!