Jump to content

PHP/XML help


Vince889

Recommended Posts

Okay... this one is kind of complicated... for me, anyways.But I will try to be as clear as possible.

 

I am using PHP's SimpleXML plugin to handle this XML document generated from Yahoo's API. Incase you aren't familiar, Yahoo's API generates thisupon request.

 

As you can see, the queries the Yahoo Answers database and returns some questions on "PHP". I need to loop through this document and grab the Subject, Content, Date, Link, and Chosen Answer nodes from each Question node. And of course, they will need to be stored in a variable for later echo'ing.

 

I think XPath is what I should be doing, but I have no idea about how I should loop through it and target those specific nodes only.

 

$req = "http://answers.yahooapis.com/AnswersService/V1/questionSearch?appid=YahooDemo&query=php";
$res = file_get_contents($req);
$xml = simplexml_load_string($res);

 

That's about as far as I got. Can anyone help? Also, if I'm not clear enough, please let me know!

Link to comment
https://forums.phpfreaks.com/topic/211845-phpxml-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.