How to break down and parse specific Wikipedia text
-
11-11-2019 - |
Pergunta
I'm have the following working example to retrieve a specific Wikipedia page that returns a SimpleXMLElement Object:
ini_set('user_agent', 'michael@example.com');
$doc = New DOMDocument();
$doc->load('http://en.wikipedia.org/w/api.php?action=parse&page=Main%20Page&format=xml');
$xml = simplexml_import_dom($doc);
print '<pre>';
print_r($xml);
print '</pre>';
Which returns:
SimpleXMLElement Object
(
[parse] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Main Page
[revid] => 472210092
[displaytitle] => Main Page
)
[text] => <body><table id="mp-topbanner" style="width: 100%;"...
Silly question/mind blank. What I am trying to do is capture the $xml->parse->text element and in-turn parse that. So ultimately what I want returned is the following object; how do I achieve this?
SimpleXMLElement Object
(
[body] => SimpleXMLElement Object
(
[table] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => mp-topbanner
[style] => width:100% ...
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow