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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:45:19+00:00 2026-06-08T22:45:19+00:00

Here is the code first rates.xml <?xml version=1.0 encoding=UTF-8?> <main> <unittype id=24944> <date value=2020-10-10>

  • 0

Here is the code first

rates.xml

<?xml version="1.0" encoding="UTF-8"?>
<main>
     <unittype id="24944">
          <date value="2020-10-10">
               <baserate>45.50</baserate>
               <closed>0</closed>
               <unitsavailable>2</unitsavailable>
          </date>
     </unittype>
     <unittype id="24944">
          <date value="2020-10-11" value2="2020-10-13">
               <baserate>99</baserate>
               <minimumstay>2</minimumstay>
               <unitsavailable>9</unitsavailable>
          </date>
          <date from="2020-10-15" to="2020-10-20">
                <closed>1</closed>
          </date>
     </unittype>
     <unittype id="24946">
          <date value="2020-10-10">
               <unitsavailable>0</unitsavailable>
               <closed>1</closed>
          </date>
     </unittype>
</main>

and here is the index.php

<?php
$xml = simplexml_load_file("xml_files/rates.xml");
//$xml = new SimpleXMLElement($xml);
$room_id = 24944;
$date = "2020101";
$hotel = $xml -> xpath('/main/unittype[@id = "'.$room_id.'"]/date[number(translate(@value,\'-\',\'\')) >"' .$date.'" ]');
var_dump($hotel);

foreach($hotel as $room) {
    //var_dump($room);
    echo "<br /><br />";
    echo "The room with the ID: {$room->unittype} <br />";
    echo "Date: {$room[0]->attributes()['value']}<br />";
    echo "Room Price: {$room->baserate}<br />
    Room min stay: {$room->unitsavailable}<br />";
}
?>

now I am trying as you see to get to the id in the unittype with the room that was selected, as $room->unittype but of course it’s not working so does anyone know how to solve this?

the output of the var_dump($hotel) is

array (size=2)
  0 => 
    object(SimpleXMLElement)[2]
      public '@attributes' => 
        array (size=1)
          'value' => string '2020-10-10' (length=10)
      public 'baserate' => string '45.50' (length=5)
      public 'closed' => string '0' (length=1)
      public 'unitsavailable' => string '2' (length=1)
  1 => 
    object(SimpleXMLElement)[3]
      public '@attributes' => 
        array (size=2)
          'value' => string '2020-10-11' (length=10)
          'value2' => string '2020-10-13' (length=10)
      public 'baserate' => string '99' (length=2)
      public 'minimumstay' => string '2' (length=1)
      public 'unitsavailable' => string '9' (length=1)
  • 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-08T22:45:21+00:00Added an answer on June 8, 2026 at 10:45 pm
    $room->unittype->attributes()->id;
    

    Reference

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's the main code at first I thought is was the message box but
Here's sample model classes, which being use with Entity Framework Code First: public class
I have a simple situation here. lets face html code first => <form name=geoKey
i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
Let me first put the code snippets here. I am just using the ASP.NET
First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
Here is the code: string str; cin>>str; cout<<first input:<<str<<endl; getline(cin, str); cout<<line input:<<str<<endl; The
So, first off here's my code to open the dotx and create a new
Just playing around with memcache for the first time; here's my code: $memcache =
So, here's my question: Why won't the code in the first snippet work when

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.