/** * Get specific XML tag or attribute value. * * @param string $tag * Tag name (examples: guid, media:content) * @param string $attribute * Tag attribute * * @return array|false Tag values or error */ public function getTag($tag, $attribute = '') { // convert to xPath attribute query if ($attribute !== '') { $attribute = '/@' . $attribute; } // construct query $query = './/' . $tag . $attribute; $elements = XmlParser::getXPathResult($this->xml, $query, $this->namespaces); if ($elements === false) { // xPath error return false; } return array_map(function ($element) { return (string) $element; }, $elements); }