diff options
| author | Markus Birth <markus@birth-online.de> | 2013-04-09 12:23:49 +0200 |
|---|---|---|
| committer | Markus Birth <markus@birth-online.de> | 2013-04-09 12:23:49 +0200 |
| commit | ac7a77656274dbfaeebbaa3b9240c8dbe5579300 (patch) | |
| tree | 978d91faa2bdca42ec25a90f0d4b95b45a51ce8d /tests | |
| parent | 62f838a10447abb8373c087f7b746e625352bd3f (diff) | |
| download | yafpp-ac7a77656274dbfaeebbaa3b9240c8dbe5579300.tar.gz yafpp-ac7a77656274dbfaeebbaa3b9240c8dbe5579300.zip | |
Added XPath test script
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/xpath.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/xpath.php b/tests/xpath.php new file mode 100644 index 0000000..1269ae5 --- /dev/null +++ b/tests/xpath.php @@ -0,0 +1,33 @@ +<?php + +$config = array( + 'type' => 'xpath', + 'xpath' => 'div[@class="bacontent"]', +); + +$article = array( + 'link' => 'http://www.berlin.de/polizei/presse-fahndung/archiv/383117/index.html', + 'content' => 'This is the feed content', + 'plugin_data' => '', +); + +$doc = new DOMDocument(); +$html = file_get_contents($article['link']); +$doc->loadHTML($html); + +if ($doc) { + $basenode = false; + $xpath = new DOMXPath($doc); + $entries = $xpath->query('(//'.$config['xpath'].')'); // find main DIV according to config + + var_dump($entries); + + if ($entries->length > 0) $basenode = $entries->item(0); + + if ($basenode) { + $article['content'] = $doc->saveXML($basenode); + $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; + } +} + +print_r($article);
\ No newline at end of file |
