0

I am trying to implement the Expedia API and I have run into an issue. I need to get the description tag of a parent tag with a certain attribute number. This is what I have tried and it is not working:

$data->RoomTypes->RoomType['roomCode="17918"']->description;

I do not know if this is the right syntax. If I were going to look for it in mysql it would look something like this:

mysql_query("SELECT description FROM RoomType WHERE roomCode = '17918'");

How would I go about doing this in xml with php?? Any help would be greatly appreciated!! Thank you in advance!

1 Answer 1

1

Generally speaking, for XML queries, node attributes must be prefaced with a @ for matching. You haven't specified what XML library you're using but if it's following conventions/standards, you'd probably want

$data->RoomTypes->RoomType['@roomCode="17918"']->description;
                            ^---

instead.

Sign up to request clarification or add additional context in comments.

2 Comments

It did not work :(... I know the xml library is working because I can get any other data from it. using the same syntax.. just can't seem to find this. Thank you though!
There are various RoomType responses... could this affect it somehow? Should I place it into a loop?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.