打印出所有的属性节点方法

<?php

//打印出所有的属性节点方法
function dumpNodes($node){

    if($node == null)   return;

    if($node->hasAttributes()){
        $length = $node->attributes->length;
        for ($i = 0; $i < $length; ++$i) {
            $name = $node->attributes->item($i)->name;
            var_dump($node->attributes->item($i));
        }
    }

    if($node->childNodes){
        foreach ($node->childNodes as $child){
            $this->dumpNodes($child);
        }
    }

}

?>