xml
我的一个方法$api->responseXML 在页面上打印出来显示是一些标准的xml,请问我该如何解码
如下:
我解码他的代码如下 求高手指教
$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);