function dom_to_simple_array($domnode, &$array) { $array_ptr =& $array; $domnode = $domnode->firstChild; while (!is_null($domnode)) { if (!(trim($domnode->nodeValue) == "")) { switch ($domnode->nodeType) { case XML_TEXT_NODE: $array_ptr['cdata'] = $domnode->nodeValue; break; case XML_ELEMENT_NODE: $array_ptr =& $array[$domnode->nodeName][]; if ($domnode->hasAttributes()) { $attributes = $domnode->attributes; if (!is_array($attributes)) { break; } foreach ($attributes as $index => $domobj) { $array_ptr[$index] = $array_ptr[$domobj->name] = $domobj->value; } } break; } if ($domnode->hasChildNodes()) { dom_to_simple_array($domnode, $array_ptr); } } $domnode = $domnode->nextSibling; } }
<ul> <?php //Here we will echo the headings //Retrieve pluginlist $availplugins = array(); $url = $TAGONTONET_REST_AJAX_URL . 'r=ListPlugins'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); //Parse the xml document $domdoc = new DOMDocument(); $domdoc->loadXML($result); //Simple $aData = array(); dom_to_simple_array($domdoc, $aData); //The xml document has been parsed. Building array of pluginnames foreach ($aData['tagonto'][0]['resource'] as $res) { $availplugins[] = $res['name'][0]['cdata']; } $plcount = 0; //Getting pl data foreach ($availplugins as $plug) { echo '<li><a href="'; echo $TAGONTONET_XSL_TRANSLATOR; echo '?urltoget=' . urlencode($TAGONTONET_REST_AJAX_URL . 'r=GetResources&tag=' . $_GET["tag"] . '&pl=' . $plug) . '#container' . $plcount; //Ajax call echo '">'; echo $plug; echo '</a></li>'; echo "\n\r";