.. Instead, it is used as a passthrough.
See also: SimpleXMLElement
Inheritance: use trait Box\Spout\Reader\Wrapper\XMLInternalErrorsHelper
Exemplo n.º 1
0
 /**
  * If the text node has the attribute 'xml:space="preserve"', then preserve whitespace.
  *
  * @param \Box\Spout\Reader\Wrapper\SimpleXMLElement $textNode The text node element (<t>) whitespace may be preserved
  * @return bool Whether whitespace should be preserved
  */
 protected function shouldPreserveWhitespace($textNode)
 {
     $spaceValue = $textNode->getAttribute('space', 'xml');
     return $spaceValue === 'preserve';
 }
Exemplo n.º 2
0
    /**
     * @return void
     */
    public function testRemoveNodeMatchingXPath()
    {
        $xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<worksheet>
    <sheetData>
        <row r="1">
            <c r="A1"><v>0</v></c>
            <c r="A2"><v>1</v></c>
        </row>
    </sheetData>
</worksheet>
XML;
        $element = new SimpleXMLElement($xml);
        $this->assertNotNull($element->getFirstChildByTagName('sheetData'));
        $element->removeNodesMatchingXPath('//sheetData');
        $this->assertNull($element->getFirstChildByTagName('sheetData'));
    }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 /**
  * Wraps the given element into an instance of the wrapper
  *
  * @param \SimpleXMLElement $element Element to be wrapped
  * @return SimpleXMLElement|null The wrapped element or NULL if the given element is invalid
  */
 protected function wrapSimpleXMLElement(\SimpleXMLElement $element)
 {
     $wrappedElement = null;
     $elementAsXML = $element->asXML();
     if ($elementAsXML !== false) {
         $wrappedElement = new SimpleXMLElement($elementAsXML);
     }
     return $wrappedElement;
 }
Exemplo n.º 5
0
 /**
  * Extracts style attributes from the "xf" nodes, inside the "cellXfs" section.
  * For simplicity, the styles attributes are kept in memory. This is possible thanks
  * to the reuse of styles. So 1 million cells should not use 1 million styles.
  *
  * @param SimpleXMLElement $cellXfsNode The "cellXfs" node
  * @return void
  */
 protected function extractStyleAttributes($cellXfsNode)
 {
     foreach ($cellXfsNode->children() as $xfNode) {
         $this->stylesAttributes[] = [self::XML_ATTRIBUTE_NUM_FMT_ID => intval($xfNode->getAttribute(self::XML_ATTRIBUTE_NUM_FMT_ID)), self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT => !!$xfNode->getAttribute(self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT)];
     }
 }