Someone
public php v1 · immutable function getContent($node, $nodeContent = "") { foreach($node->childNodes as $childNode) { $nodeName = $childNode->nodeName; $nodeValue = $childNode->nodeValue; if($childNode->nodeType == XML_TEXT_NODE) { $nodeContent .= $nodeValue; } else { $nodeContent .= "<$nodeName "; foreach ($childNode->attributes as $nodeAtt) $nodeContent .="{$nodeAtt->nodeName}='{$nodeAtt->nodeValue}'"; $nodeContent .= ">" . getContent($childNode) . "</$nodeName>"; } } return $nodeContent; }