我得到以下 XML 字符串作为 BING 的响应(注意:COMPOSITE 结果),我尝试并尝试将条目(内联-> 提要-> 条目)扫描到 for 循环但失败.. 我用来扫描的代码结果如下
$xml = new SimpleXMLElement($rs);
$i=0;
if ( $xml->entry->link ) {
$feeds = $xml->entry->link->children('m', TRUE)->inline->entry;
foreach ( $feeds as $results) {
$i++;
echo $data=(string)$results->content;
$result = $data->children('m', TRUE)->properties->children('d', TRUE);
echo "ss".$clickurl = $result->Url;
$url = urldecode($clickurl);
$search[$i]['url'] = str_replace("&", "&", $url);// for the vali
$search[$i]['abstract'] = (string)$result->Description;
$search[$i]['title'] = (string)$result->Title;
$search[$i]['rank'] = $i;
} //foreach
}
return $search;
*你能告诉我我在这里缺少什么吗?我不知道如何<m:inline> <feed>
使用 simpleXML 对象访问数据集,微软支持团队的回答是 PHP 不是他们的语言,所以他们无法帮助我,请我使用论坛/stackoverflow。*
<feed xmlns:base="https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Composite" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">keyword</title>
<subtitle type="text">Bing Search API</subtitle>
<id>https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Composite?Query='keyword'</id>
<rights type="text" />
<updated>2012-08-07T18:29:09Z</updated>
<entry>
<id>https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Composite?Query='keyword'&$skip=0&$top=1</id>
<title type="text">ExpandableSearchResult</title>
<updated>2012-08-07T18:29:09Z</updated>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Web" type="application/atom+xml;type=feed" title="Web" href="ExpandableSearchResultSet(guid'3947df4e-b3b3-4be7-b25b-77852c8d312a')/Web">
<m:inline>
<feed xmlns:base="https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/ExpandableSearchResultSet(guid'3947df4e-b3b3-4be7-b25b-77852c8d312a')/Web" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Web</title>
<subtitle type="text">Bing Search API</subtitle>
<id>https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/ExpandableSearchResultSet(guid'3947df4e-b3b3-4be7-b25b-77852c8d312a')/Web</id>
<rights type="text"></rights>
<updated>2012-08-07T18:29:09Z</updated>
<link rel="next" href="https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query='keyword'&$skip=3&$top=50" />
<entry>
<id>https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/ExpandableSearchResultSet(guid'3947df4e-b3b3-4be7-b25b-77852c8d312a')/Web?$skip=1&$top=1</id>
<title type="text">WebResult</title>
<updated>2012-08-07T18:29:09Z</updated>
<content type="application/xml">
<m:properties>
<d:ID m:type="Edm.Guid">a6c62628-0012-42a2-b65c-513c82f523d1</d:ID>
<d:Title m:type="Edm.String">title ...</d:Title>
<d:Description m:type="Edm.String">title: ...</d:Description>
<d:DisplayUrl m:type="Edm.String">sss.newikis.com/dd.html</d:DisplayUrl>
<d:Url m:type="Edm.String">http://ss.newikis.com/ss.html</d:Url>
</m:properties>
</content>
</entry>
</feed>
</m:inline>
</link>
<content type="application/xml">
<m:properties>
<d:ID m:type="Edm.Guid">3947df4e-b3b3-4be7-b25b-77852c8d312a</d:ID>
<d:WebTotal m:type="Edm.Int64">3</d:WebTotal>
<d:WebOffset m:type="Edm.Int64">0</d:WebOffset>
<d:AlteredQuery m:type="Edm.String"></d:AlteredQuery>
<d:AlterationOverrideQuery m:type="Edm.String"></d:AlterationOverrideQuery>
</m:properties>
</content>
</entry>
</feed>
谁能帮我用上面的代码使用 PHP 解决这个问题?