Possible Duplicate:
Getting content using wikipedia API
Using PHP, how do I get the first paragraph of a Wikipedia article with the MediaWiki API?
This is mainly an XML-related question.
I'm trying to do this using the MediaWiki API.
I've managed to get a response in XML format (can change to JSON if easier), and I see all the content I need in the response. Example:
http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=War%20and%20Peace&prop=revisions&rvprop=content&format=xmlfm
I used xmlfm here for formatting reasons. In PHP I'm doing:
$request = "http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=War%20and%20Peace&prop=revisions&rvprop=content&format=xml";
$response = @file_get_contents($request);
$wxml = simplexml_load_string($response);
var_dump($wxml);
Which prints out everything in the XML. My question is, how do I get the first paragraph out of this?
I can parse it from the full article, so basically what I'm asking is, how do I get the article text from this XML? Of course, if there's a way to go for the first paragraph directly, that would be best.