]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/XML.php
Use HTTPRequestOptions constants for HTTPClient::post()
[friendica.git] / src / Util / XML.php
index 4eed3a85f84eb511b0859521d75be1a34a99a760..7b4539ba8cdd10a066ba44c52730d432ddb90168 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -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
         *