registerXPathNamespace() public method

Creates a prefix/ns context for the next XPath query
See also: SimpleXMLElement::registerXPathNamespace
public registerXPathNamespace ( string $prefix, string $namespace ) : boolean
$prefix string The namespace prefix to use in the XPath query for the namespace given in "namespace".
$namespace string The namespace to use for the XPath query. This must match a namespace in use by the XML document or the XPath query using "prefix" will not return any results.
return boolean TRUE on success or FALSE on failure.
Ejemplo n.º 1
0
 /**
  * Loads the contents of the given file in an XML parser and register the given XPath namespace.
  *
  * @param string $xmlFilePath The path of the XML file inside the XLSX file
  * @param string $mainNamespace The main XPath namespace to register
  * @return \Box\Spout\Reader\Wrapper\SimpleXMLElement The XML element representing the file
  */
 protected function getFileAsXMLElementWithNamespace($xmlFilePath, $mainNamespace)
 {
     $xmlContents = $this->globalFunctionsHelper->file_get_contents('zip://' . $this->filePath . '#' . $xmlFilePath);
     $xmlElement = new SimpleXMLElement($xmlContents);
     $xmlElement->registerXPathNamespace('ns', $mainNamespace);
     return $xmlElement;
 }