From f660a1a7bd79b66f8c8ff7e1a53c047e99150fe8 Mon Sep 17 00:00:00 2001 From: Andy Lester Date: Mon, 27 Feb 2012 16:19:14 -0600 Subject: [PATCH] added another PHP example --- s/index.md | 1 + s/php.md | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/s/index.md b/s/index.md index b0e5879..fdbc2fb 100644 --- a/s/index.md +++ b/s/index.md @@ -19,6 +19,7 @@ This site shows you how. Thanks to the following folks for their contributions: +* Anubhava Srivastava * Nathan Mahdavi * Jeffrey Kegler * Bill Ricker diff --git a/s/php.md b/s/php.md index ca512ad..45d2d80 100644 --- a/s/php.md +++ b/s/php.md @@ -11,6 +11,14 @@ HTML parsing in PHP is done with the } $html = $dom->saveHTML(); +Here's an example for pulling out any `` tags with the `nofollow` attribute: + + $doc = new DOMDocument(); + libxml_use_internal_errors(true); + $doc->loadHTML($html); // loads your HTML + $xpath = new DOMXPath($doc); + // returns a list of all links with rel=nofollow + $nlist = $xpath->query("//a[@rel='nofollow']"); # Notes