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 7650793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:20:37+00:00 2026-05-31T11:20:37+00:00

Hello I am getting xml feed from expedia and trying to parse it onto

  • 0

Hello I am getting xml feed from expedia and trying to parse it onto the screen. It is not returning the data, and I can not figure out why. the only thing that will return is activePropertyCount. Here is the url where I am doing this if you want to take a look: http://travellinginmexico.com/test/index.php and here is the xml that I am trying to parse: http://travellinginmexico.com/test/data.xml

My code:

<?php 
$post_string = 'type=xml&cid=55505&minorRev=5&apiKey=4sr8d8bsn75tpcuja6ypx5g3&locale=en_US&currencyCode=USD&customerIpAddress=10.184.2.9&customerUserAgent=Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/535.11+(KHTML,+like+Gecko)+Chrome/17.0.963.79+Safari/535.11&customerSessionId=&xml=<HotelListRequest><arrivalDate>04/05/2012</arrivalDate><departureDate>04/07/2012</departureDate><RoomGroup><Room><numberOfAdults>2</numberOfAdults></Room><Room><numberOfAdults>2</numberOfAdults><numberOfChildren></numberOfChildren></Room></RoomGroup><city>Cancun</city><countryCode>MX</countryCode><supplierCacheTolerance>MED_ENHANCED</supplierCacheTolerance></HotelListRequest> ';
$path = "http://api.ean.com/ean-services/rs/hotel/v3/list"; //Relative path to the file with $_POST parsing
$ch = curl_init($path); 
$fp = fopen('data.xml','w');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); //Send the data to the file
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml')); 
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FILE, $fp);
$val = curl_exec($ch);
curl_close($ch);//Close curl session
fclose($fp); //Close file overwrite

 $data = simplexml_load_file('data.xml');
    echo "<ul id=\"data\">\n";
    foreach ($data as $info):
        $title=$info->HotelList;
        $add=$info->address1;
        $count=$info['activePropertyCount'];
        echo "<li><div class=\"title\">",$title,"</div><div class=\"artist\">by ",$add,"</div><time>",$count,"</time></li>\n";
    endforeach;
    echo "</ul>";

?>
  • 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-05-31T11:20:38+00:00Added an answer on May 31, 2026 at 11:20 am

    It appears that you are not trying to retrieve your data from the correct part of the XML object. I have updated your code to read from the HotelList->HotelSummary section, and it will now display the hotel name and address properly.

    //Use Curl to get XML here.
    
    $data = simplexml_load_file('data.xml');
    
    //Uncomment this to view the parsed XML on screen.
    /*
    echo '<pre>';
    print_r($data->HotelList);
    echo '</pre>';
    */
    
    echo "<ul id=\"data\">\n";
    foreach($data->HotelList->HotelSummary as $info):
        $title=$info->name;
        $add=$info->address1;
        $count=$data->HotelList['activePropertyCount'];
        echo "<li><div class=\"title\">",$title,"</div><div class=\"artist\">by ",$add,"</div><time>",$count,"</time></li>\n";
    endforeach;
    echo "</ul>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting really fustrated with this... With this simple xml: <?xml version='1.0'?> <root> <data>hello</data>
Hello I'm getting this error, while trying to save serial number to XML File.
Hello I'm trying to insert some XML data into a table on SQL Server
When loading an image from the web I am getting a black screen. I
I been trying to get the Spring Batch Hello World 3 example running from
I been trying to get the Spring Batch Hello World 3 example running from
Hello I am trying to run my Eclipse + Maven from a flash drive.
Hello all in my iphone application after sending login xml request am getting following
hello i have a problem in getting picture from the url contained in the
In my application I want to post from my android application XML data in

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.