]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/XML.php
Merge pull request #9345 from annando/issue-9344
[friendica.git] / src / Util / XML.php
index 4eed3a85f84eb511b0859521d75be1a34a99a760..039247cc7503f74195dc3c0888b8a86587b276de 100644 (file)
@@ -488,6 +488,21 @@ class XML
                return $first_item->attributes;
        }
 
+       public static function getFirstValue($xpath, $search, $context)
+       {
+               $result = $xpath->query($search, $context);
+               if (!is_object($result)) {
+                       return '';
+               }
+
+               $first_item = $result->item(0);
+               if (!is_object($first_item)) {
+                       return '';
+               }
+
+               return $first_item->nodeValue;
+       }
+
        /**
         * escape text ($str) for XML transport
         *