xml文件结构如下
php代码解析:
$url="";//输出xml的URL $dom = new DOMDocument('1.0', 'utf-8'); $dom->load($url);
这样我们捕获里XML数据,然后一点点截取,这段XML有多个URL节点,需要利DOMPATH解析
$xpath = new DOMXPath($dom); $node = '//url'; $length = $xpath->query($node)->length;
然后根据每个url内的字节点去获取数据
for($i = 0; $i < $length; $i++) { $data = array(); $m_date = date('Y-m-d', strtotime($xpath->query($node.'['.($i+1).']/date')->item(0)->nodeValue)); $m_start = $xpath->query($node.'['.($i+1).']/start')->item(0)->nodeValue; $m_end = $xpath->query($node.'['.($i+1).']/end')->item(0)->nodeValue; $m_title = $xpath->query($node.'['.($i+1).']/title')->item(0)->nodeValue; $m_format = $xpath->query($node.'['.($i+1).']/format')->item(0)->nodeValue; $m_season = $xpath->query($node.'['.($i+1).']/season')->item(0)->nodeValue; $m_round = $xpath->query($node.'['.($i+1).']/round')->item(0)->nodeValue; /*$homeTeam = $xpath->query($node.'['.($i+1).']/homeTeam')->item(0)->nodeValue; if(empty($homeTeam)) continue; $guestTeam = $xpath->query($node.'['.($i+1).']/guestTeam')->item(0)->nodeValue; if(empty($guestTeam)) continue;*/ $homeTeam = $xpath->query($node.'['.($i+1).']/homeTeam')->item(0)->nodeValue; $guestTeam = $xpath->query($node.'['.($i+1).']/guestTeam')->item(0)->nodeValue; if(empty($guestTeam) || empty($homeTeam)) { if($m_title){ $temp_title=explode(" ", $m_title); list($homeTeam,$guestTeam)=explode("vs", $temp_title[1]); unset($temp_title); } } if(empty($homeTeam)) continue; if(empty($guestTeam)) continue; }
我最强舞者 (I, Best Dancer)安卓版v8
我最强舞者(I, Best Dancer)是一款休闲放置类手
迷你世界国服版本2024 v1.43.0
迷你世界国服版本2024是一款自由度非常高的沙盒游戏,玩法和
烹饪乐园 安卓版v1.23.6
烹饪乐园(Cooking Town)是一款非常好玩的餐厅模拟
迷你世界小米服 最新安卓版v1.43.0
迷你世界小米版是由迷你玩科技开发的休闲模拟经营类游戏。此版本
布娃娃Sprunki沙盒 安卓版v0.0.1
布娃娃Sprunki沙盒是一个非常有趣的沙盒游戏,复古简约的