$txt = GetRemoteText($url);
if(strlen($txt) > 0)
{
$xml = simplexml_load_string($txt); //获取xml
if($xml)
{
$logo = $xml->xpath("webinfo");
$title = $xml->xpath("title");
$keywords = $xml->xpath("keywords");
$description = $xml->xpath("description"); $ret .= "var WG_Logo = \"" . $logo[0]["logo"] . "\"\r\n";
$ret .= "var WG_Title = \"" . $title[0]["title"] . "\"\r\n";
$ret .= "var WG_Keywords = \"" . $keywords[0]["keywords"] . "\"\r\n";
$ret .= "var WG_Description = \"" . $description[0]["description"] . "\"\r\n"; $group_info = "\r\nvar group_info = [\r\n";
$district_info = "\r\nvar district_info = [\r\n";
foreach ($xml->children() as $child)
{
if("gamelist" == $child->getName())
{
//组信息
foreach($child->children() as $groupChild)
{
$group_info .= "['" . $groupChild["id"] . "','" . $groupChild["gamename"] . "'],\r\n";
}
}
else if("zonelist" == $child->getName())
{
//分区信息
foreach($child->children() as $districtChild)
{
$district_info .= "['" . $districtChild["id"] . "','" . $districtChild["zonename"]
. "','" . $districtChild["starttime"] . "','" . $districtChild["gameid"]. "'],\r\n";
}
}
}
$group_info .= "];\r\n";
$district_info .= "];\r\n";
$ret .= $group_info . $district_info; $file = fopen($localJsPath, "w");
fwrite($file, $ret);
fclose($file);
}
}
$xml->xpath("webinfo")[0]["logo"] 有些php编译器通不过