Home > Backend Development > PHP Tutorial > xml解决思路

xml解决思路

WBOY
Release: 2016-06-13 12:43:29
Original
802 people have browsed it

xml
我的一个方法$api->responseXML 在页面上打印出来显示是一些标准的xml,请问我该如何解码
如下:




2
98
http://www.iisp.com/images/v4/logo.gif
http://www.iisp.com



我解码他的代码如下 求高手指教
        $dom=new DOMDocument();
$dom->load($api->responseXML);//如何把它读出来
$messages = $dom -> getElementsByTagName("imagead");//图片ad
foreach($messages as $book){
//get id
$id = $book->getAttribute('id');
//get displayPreference
$dis = $book->getElementsByTagName('displayPreference');
    $displayPreference = $dis->item(0)->nodeValue;
//get preference
$pre = $book->getElementsByTagName('preference');
$preference = $pre->item(0)->nodeValue;
// get imageUri
$ima = $book->getElementsByTagName('imageUri');
$imageUri = $ima->item(0)->nodeValue;
// get adLink
$ad = $book->getElementsByTagName('adLink');
$adLink = $ad->item(0)->nodeValue;

//save data
$imageadInfo['id'] = $id;
$imageadInfo['displayPreference'] = $displayPreference;
$imageadInfo['preference'] = $preference;
$imageadInfo['imageUri'] = $imageUri;
$imageadInfo['adLink'] = $adLink;
//save info
$imageadInfos[] = $imageadInfo; 
}
print_r($imageadInfos);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template