createProcessingInstruction('xml', 'version="1.0" encoding="utf-8"'); $resdoc->appendChild($xmlDecl); $rootElement =& $resdoc->createElement('universes'); $resdoc->appendChild($rootElement); for ($i = 0; $i < count($domains); $i++) { parseWeb($domains[$i],$rootElement, $resdoc); } $resdoc->saveXML('./fgUniverses.xml', true); header('Location: ./fgUniverses.xml'); //echo $resdoc->toNormalizedString(false,false); function parseWeb($string, &$rootElement, &$resdoc) { $xmldoc = new DOMIT_Document(); $xmldoc->expandEmptyElementTags(true); $xmldoc->setNamespaceAwareness(true); $xmldoc->useHTTPClient(true); if (strrpos($string, 'ba') || strrpos($string, 'hr')) $success = $xmldoc->loadXML("http://$string/portal/?frameset=1&lang=yu"); else $success = $xmldoc->loadXML("http://$string/portal/?frameset=1"); if (!$success) { echo "Error code: " . $xmldoc->getErrorCode(); echo "\n
"; echo "Error string: " . $xmldoc->getErrorString(); echo "Error"; return; } $childRoot =& $resdoc->createElement('index'); $childRoot->setAttribute('url',$string); $nodeList =& $xmldoc->selectNodes('//select[@name="Uni"]/option'); for ($i = 0; $i < $nodeList->getLength(); $i++){ $temp =& $nodeList->item($i); if ($temp->getAttribute('value') == "") continue; $child =& $resdoc->createElement('universe'); $name = $temp->getText(); $name = split('\.',$name,2); if (strlen($name[0]) == 1) $name[0] = '0'.$name[0]; if (strpos($string,"tw")){ $name = $name[0].'. 宇宙'; } else if (strpos($string,"ru")){ $name = $name[0].'. Вселенная'; }else { $name = $name[0].'.'.$name[1]; } $child->setAttribute('name',$name); $child->setAttribute('value',$temp->getAttribute('value')); $childRoot->appendChild($child); } $rootElement->appendChild($childRoot); } ?>