开发者

Bing search API. Colon in XML

I am trying to parse a Bing search XML resu开发者_开发问答lt, but whenever I try to access an XML element there is colon in every element.

It gives the error

Parse error: syntax error, unexpected ':' in /

Here is my PHP code

foreach ($searchresponse->web:Web->web:Results as $result)
{
    printf(" \n%s", $result->web:Description);
}

Here is the Bing XML response,

<SearchResponse Version="2.2">
-
<Query>
    <SearchTerms>ipl</SearchTerms>
</Query>
-
<web:Web>
<web:Total>2430000</web:Total>
<web:Offset>0</web:Offset>
-
<web:Results>
-
<web:WebResult>
<web:Title>Indian Premier League | IPLT20</web:Title>

What is the meaning of colon in XML tags?


Colons in XML nodes denote a namespace. It's likely you will be able to parse your XML more easily with something like DOM or SimpleXML which both have support for namespaced nodes. There's a good article here which discusses simpleXML and namespaces.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜