X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivityutils.php;h=c2c239f1d3cc68ef32872da97835f7d8ec58710c;hb=4fa286801e3ecbe07568a03c7b625f6749b771e8;hp=59f7cdcf3a987d9290609e163427f639bdd5678a;hpb=0dbdcf2936a00282114f1368ead2f5edebc6ae61;p=quix0rs-gnu-social.git diff --git a/lib/activityutils.php b/lib/activityutils.php index 59f7cdcf3a..c2c239f1d3 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -145,6 +145,34 @@ class ActivityUtils } } + /** + * Gets all immediate child elements with the given tag + * + * @param DOMElement $element element to pick at + * @param string $tag tag to look for + * @param string $namespace Namespace to look under + * + * @return array found element or null + */ + + static function children(DOMNode $element, $tag, $namespace=self::ATOM) + { + $results = array(); + + $els = $element->childNodes; + + if (!empty($els) && $els->length > 0) { + for ($i = 0; $i < $els->length; $i++) { + $el = $els->item($i); + if ($el->localName == $tag && $el->namespaceURI == $namespace) { + $results[] = $el; + } + } + } + + return $results; + } + /** * Grab the text content of a DOM element child of the current element *