Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:12:32+00:00 2026-06-09T21:12:32+00:00

I get following XML string as a response from BING (Note:COMPOSITE result), i tried

  • 0

I get following XML string as a response from BING (Note:COMPOSITE result), i tried and tried to scan into the entries (inline->feed->entry) to a for loop but failed.. the code i used to scan through the results as below

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

*can you let me what i am missing here ? I have no idea to how do i access the <m:inline> <feed> dataset using the simpleXML object, and microsoft support team answer is PHP is not their language so they can’t help me, ask me to use forums/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'&amp;$skip=0&amp;$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'&amp;$skip=3&amp;$top=50" />
          <entry>
            <id>https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/ExpandableSearchResultSet(guid'3947df4e-b3b3-4be7-b25b-77852c8d312a')/Web?$skip=1&amp;$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>

Anyone who can help me to resolve this issue using PHP with the above code ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:12:34+00:00Added an answer on June 9, 2026 at 9:12 pm

    You were very close, only missing a couple of minor (but crucial) points.

    Minimal changes needed

    You can get away with changing only three lines of your original code.

    1. Getting <entry> elements.

      $feeds = $xml->entry->link->children('m', TRUE)->inline->entry;
      

      becomes

      $feeds = $xml->entry->link->children('m', TRUE)->inline->children('', TRUE)->feed->entry;
      
    2. Getting <d:*> elements from <m:properties>.

      $result = $data->children('m', TRUE)->properties->children('d', TRUE);
      

      becomes

      $result = $results->content->children('m', TRUE)->properties->children('d', TRUE);
      
    3. Remove the following line.

      echo $data=(string)$results->content;
      

    With those changes, your script will give the resulting array that you are wanting.

    Code clean up

    The example below is a small modification of your original which builds up the $search array from the feed in a slightly tidier* way.

    * In my eyes: the reader may disagree. Tough, it’s my answer.

    $xml = new SimpleXMLElement($rs);
    
    $i = 0;
    $search = array();
    
    $entries = $xml->entry->link->children('m', TRUE)->inline->children('', TRUE)->feed->entry;
    foreach ($entries as $entry) {
        $i++;
    
        $properties = $entry->content->children('m', TRUE)->properties->children('d', TRUE);
    
        $url = (string) $properties->Url;
        $url = str_replace("&", "&amp;", urldecode($url));
    
        $search[$i] = array(
            'url'      => $url,
            'abstract' => (string) $properties->Description,
            'title'    => (string) $properties->Title,
            'rank'     => $i,
        );
    }
    

    What changed?

    1. This is the important point: As noted under “minimal changes”, the $entries line uses children('', TRUE)->feed to access the <feed> element within the <m:inline>.
    2. Variable names slightly changed to reflect the name of the XML element represented by the variable, where appropriate. I find this helps lots when working with SimpleXML.
    3. Assign everything to $search[$i] at once; this is just a personal preference as I think it looks tidier.
    4. Got rid of those weird mixed echo and assignment lines.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following text as a string from an XML-based REST API 'd':4
How can I get the connection.connection_string value from the following hibernate xml file using
From windows event viewer I can get the following xml structure: <Event xmlns=http://schemas.microsoft.com/win/2004/08/events/event> <System>
I am using the following code to get an XML data from a website
I need to send a HTTP request (and get XML response) from Flash that
(Following up on this question: Getting raw XML response from Java web service client
I have the following xml that I need to get 2 values (see *
I have the following XML: <XMLDictionary> <a>b</a> <c>d</c> <e>f</e> </XMLDictionary> I'm trying to get
Using simplexml_load_file(), if I'm parsing out XML and I get the following for image...
I want to get the Category based total of the following <?xml version=1.0 encoding=utf-8

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.