本文整理汇总了PHP中XmlParser::Parse方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlParser::Parse方法的具体用法?PHP XmlParser::Parse怎么用?PHP XmlParser::Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlParser
的用法示例。
在下文中一共展示了XmlParser::Parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchArmory
/**
* General armory fetch class
* Returns XML, HTML or an array of the parsed XML page
*
* @param int $type
* @param string $character
* @param string $guild
* @param string $realm
* @param int $item_id
* @param string $fetch_type
* @return array
*/
function fetchArmory($type = false, $character = false, $guild = false, $realm = false, $item_id = false, $fetch_type = 'array')
{
global $roster;
$url = $this->_makeUrl($type, false, $item_id, $character, $realm, $guild);
if ($fetch_type == 'html') {
$this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
}
if ($this->_requestXml($url)) {
if ($fetch_type == 'array') {
// parse and return array
$this->_initXmlParser();
$this->xmlParser->Parse($this->xml);
$data = $this->xmlParser->getParsedData();
} elseif ($fetch_type == 'simpleClass') {
// parse and return SimpleClass object
$this->_initSimpleParser();
$data = $this->simpleParser->parse($this->xml);
} else {
// unparsed fetches
return $this->xml;
}
return $data;
} else {
trigger_error('RosterArmory:: Failed to fetch ' . $url);
return false;
}
}
示例2: migrate_allxml2conf
private function migrate_allxml2conf()
{
error_log("Migrating all config from server xml config {$this->_xmlpath} \n");
$xmlparser = new XmlParser();
$xmlroot = $xmlparser->Parse($this->_xmlpath);
if ($xmlroot->HasFatalErr()) {
$this->_conferr = $xmlroot->Get(CNode::FLD_ERR);
return FALSE;
}
$root = $xmlroot->DupHolder();
$filemap = DPageDef::GetInstance()->GetFileMap(DInfo::CT_SERV);
// serv, vh, tp, admin
$filemap->Convert(0, $xmlroot, 1, $root);
// migrate all vh.xml
if (($vhosts = $root->GetChildren('virtualhost')) != NULL) {
if (!is_array($vhosts)) {
$vhosts = array($vhosts);
}
foreach ($vhosts as $vh) {
$vhname = $vh->Get(CNode::FLD_VAL);
$vhroot = $vh->GetChildVal('vhRoot');
$vhconf = $vh->GetChildVal('configFile');
$conffile = PathTool::GetAbsFile($vhconf, 'VR', $vhname, $vhroot);
$vhdata = new CData(DInfo::CT_VH, $conffile);
if (($pos = strpos($vhconf, '.xml')) > 0) {
$vhconf = substr($vhconf, 0, $pos) . '.conf';
$vh->SetChildVal('configFile', $vhconf);
}
}
}
// migrate all tp.xml
if (($tps = $root->GetChildren('vhTemplate')) != NULL) {
if (!is_array($tps)) {
$tps = array($tps);
}
foreach ($tps as $tp) {
$tpconf = $tp->GetChildVal('templateFile');
$conffile = PathTool::GetAbsFile($tpconf, 'SR');
$tpdata = new CData(DInfo::CT_TP, $conffile);
if (($pos = strpos($tpconf, '.xml')) > 0) {
$tpconf = substr($tpconf, 0, $pos) . '.conf';
$tp->SetChildVal('templateFile', $tpconf);
}
}
}
$buf = '';
$this->before_write_conf($root);
$root->PrintBuf($buf);
touch($this->_path);
$this->write_file($this->_path, $buf);
$this->copy_permission($this->_xmlpath, $this->_path);
$migrated = $this->_xmlpath . '.migrated.' . time();
if (defined('SAVE_XML')) {
copy($this->_xmlpath, $migrated);
} else {
rename($this->_xmlpath, $migrated);
}
if (defined('RECOVER_SCRIPT')) {
file_put_contents(RECOVER_SCRIPT, "mv {$migrated} {$this->_xmlpath}\n", FILE_APPEND);
}
error_log(" converted {$this->_xmlpath} to {$this->_path}\n\n");
}