xml解决思路

WBOY
WBOYOriginal
2016-06-13 12:43:29803browse

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);

Statement:
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