//一个好玩的使用dom遍历xml的方法
<?php
$dom = new DOMDocument();
$dom->load('xxx.xml');
$root = $dom->documentElement;
processchildren ($root);
function processchildren($node)
{
$children = $node->childNodes;
foreach ($children as $elem ) {
if ($elem->nodeType == XML_TYPE_NODE) {
if (strlen(trim($elem->nodeValue))) {
print trim($elem->nodeValue)."/n";
}
}
else if ($elem->nodeType == XML_ELEMENT_NODE) {
processchildren($elem);
}
}
}
?>