Hi i have problem with this code, i found it on the internet and when i tested it it gave me the following errorcode:
Parse error: parse error, unexpected $end on line 52
Here is the script:
<?php
function walkDom($node, $level = 0)
{
$indent =";
for ($i = 0; $i nodeType != XML_TEXT_NODE)
{
echo $indent.''.$node->nodeName.'';
if( $node->nodeType == XML_ELEMENT_NODE )
{
$attributes = $node->attributes;
foreach($attributes as $attribute)
{
echo ', '.$attribute->name.'='.$attribute->value;
}
}
if( strlen(trim($node->childNodes->item(0)->nodeValue)) > 0 && count($cNodes) == 1 ) {
echo ".$indent.'(contains='.$node->childNodes->item(0)->nodeValue.')';
}
echo ";
}
$cNodes = $node->childNodes;
if (count($cNodes) > 0)
{
$level++ ;
foreach($cNodes as $cNode) {
walkDom($cNode, $level);
$level = $level – 1;
}
}
}
$doc = new DOMDocument();
$doc->loadHTMLFile('http://www.google.se');
walkDom($doc);
?>