Created
January 12, 2010 09:58
-
-
Save up1/275069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function readXml($domnode, &$array) | |
{ | |
$array_ptr = &$array; | |
$domnode = $domnode->firstChild; | |
while (!is_null($domnode)) | |
{ | |
switch ($domnode->nodeType) | |
{ | |
case XML_TEXT_NODE: if(!(trim($domnode->nodeValue) == "")) | |
$array_ptr['cdata'] = $domnode->nodeValue; | |
break; | |
case XML_CDATA_SECTION_NODE: if(!(trim($domnode->nodeValue) == "")) | |
$array_ptr['cdata'] = $domnode->nodeValue; | |
break; | |
case XML_ELEMENT_NODE: | |
$array_ptr = &$array[$domnode->nodeName][]; | |
if ($domnode->hasAttributes() ) | |
{ | |
$attributes = $domnode->attributes; | |
foreach ($attributes as $index => $domobj) | |
{ | |
$array_ptr[$domobj->name] = $domobj->value; | |
} | |
} | |
break; | |
} | |
if ( $domnode->hasChildNodes() ) | |
{ | |
$this->readXml($domnode, $array_ptr); | |
} | |
$domnode = $domnode->nextSibling; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment