Trying to parse a YouTube feed using PHP
simplexml_load_file();
I am able to access other tags pretty simply using
$xml->id;
When I try to access
<openSearch:totalResults>
with
$xml->openSearch->totalResults;
I don’t get any results
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
openSearchis a namespace – it’s not the name of the tag, or a parent, or anything like that. Somewhere in the document there will be an attribute calledxmlns:openSearchwhich defines the openSearch namespace (with an URL).You can use the
childrenmethod to get children of a certain namespace, and do something like:(You can also use the full URL for the namespace instead of ‘openSearch’ and leave the
trueoff of the end, which may be beneficial if they ever change their markup or you parse similar feeds from elsewhere which use a different namespace prefix)