Export the data of all the libraries.

@param \SimpleXMLElement $xml the parent XML element
322606
public static function exportList(\SimpleXMLElement $xml)
    {
        $list = self::getList();
        $nxml = $xml->addChild('systemcaptcha');

        foreach ($list as $sc) {
            $sc->export($nxml);
        }
    }
62534
public static function parse($xml)
    {
        $backup = libxml_disable_entity_loader(true);

        $result = self::normalize(simplexml_load_string(self::sanitize($xml), 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_NOCDATA | LIBXML_NOBLANKS));

        libxml_disable_entity_loader($backup);

        return $result;
    }
1025162
protected function setAttributes(SimpleXMLElement $element)
    {
        $nb_parent = $this->nb_data_object->getTranslatedObject();
        if ($nb_parent !== null) {
            $nb_language = $nb_parent->getLanguage($this->nb_data_object->getLanguageId());
            $element->addAttribute('lang', $nb_language->grantHash(true));
            $this->putAttributesFromList($element, array(
                'nb_site_target_section_main_image' => 'image'
            ), false);
        }
    }
997999
protected function childToArray(SimpleXmlElement $xml, $name)
    {
        if (!isset($xml->{$name})) {
            return array();
        }

        return $xml->{$name}->toPhpValue('array');
    }
332159
public function appendChildFromXmlString($xml)
    {
        $dom = new \DOMDocument;
        $dom->loadXML($xml);

        $element = simplexml_import_dom($dom);

        $this->appendChildNode($element);
    }
1181285
protected function parseXml($xml) {
        if (!$xml){
            return false;
        }

        //response from send, confirm, estimate, void
        if (isset($xml->TransportDocument)) {
            $this->doc = (string)$xml->TransportDocument->PdfDocument;
            $this->checksum = (string)$xml->TransportDocument->Checksum;
        }
    }
764291
private function validate(SimpleXMLElement $xml): void
    {
        if ($xml->getName() !== 'phpdocumentor') {
            throw new InvalidArgumentException(
                sprintf('Root element name should be phpdocumentor, %s found', $xml->getName())
            );
        }
    }
1053301
public static function xmlToArray($xml) {
        $arr = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
        return $arr;
    }
844601
protected function xmlDeserialize($xml)
    {
        $array = [];

        if (!$xml instanceof SimpleXMLElement)
        {
            $xml = new SimpleXMLElement($xml);
        }

        foreach ($xml->children() as $key => $child)
        {
            $value = (string) $child;
            $_children = $this->xmlDeserialize($child);
            $_push = ( $_hasChild = ( count($_children) > 0 ) ) ? $_children : $value;

            if ( $_hasChild && !empty($value) && $value !== '' )
            {
                $_push[] = $value;
            }

            $array[$key] = $_push;
        }

        return $array;
    }
620140
private function _asXml($simpleXml)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->loadXML($simpleXml->asXML());
        $dom->formatOutput = true;

        return $dom->saveXML();
    }
1060780
public function writeXml($xml)
    {
        if ($this->writeObjectReference($xml)) {
            return $this;
        }

        if(is_string($xml)) {
            //nothing to do
        } else if ($xml instanceof DOMDocument) {
            $xml = $xml->saveXml();
        } else if ($xml instanceof SimpleXMLElement) {
            $xml = $xml->asXML();
        } else {
            require_once 'Zend/Amf/Exception.php';
            throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement');
        }

        $this->writeBinaryString($xml);

        return $this;
    }
795612
public static function formXml($xml, $file)
    {
        $xml = simplexml_load_string($xml);
        /** @var  $dataArray \SimpleXMLElement[] */
        $dataArray = $xml->attributes();

        $dataFileInfo = new DataFileInfo();
        if (isset($dataArray['Id'])) {
            $dataFileInfo->setId($dataArray['Id']->__toString());
        }
        if (isset($dataArray['Filename'])) {
            $dataFileInfo->setFilename($dataArray['Filename']->__toString());
        }
        if (isset($dataArray['ContentType'])) {
            $dataFileInfo->setContentType($dataArray['ContentType']->__toString());
        }
        if (isset($dataArray['MimeType'])) {
            $dataFileInfo->setMimeType($dataArray['MimeType']->__toString());
        }
        if (isset($dataArray['Size'])) {
            $dataFileInfo->setSize($dataArray['Size']->__toString());
        }
        if (isset($dataArray['DigestType'])) {
            $dataFileInfo->setDigestType($dataArray['DigestType']->__toString());
        }
        if (isset($dataArray['DigestValue'])) {
            $dataFileInfo->setDigestValue($dataArray['DigestValue']->__toString());
        }
        if (isset($dataArray['DfData'])) {
            $dataFileInfo->setDfData($dataArray['DfData']->__toString());
        } elseif (file_exists($file)) {
            $dataFileInfo->setDfData(base64_encode(file_get_contents($file)));
        }

        // TODO: validate data

        return $dataFileInfo;
    }
1020527
public function process($xml)
    {
        // Sanitize if necessary:
        if ($this->sanitize) {
            $xml = $this->sanitizeXml($xml);
        }

        // Parse the XML (newer versions of LibXML require a special flag for
        // large documents, and responses may be quite large):
        $flags = LIBXML_VERSION >= 20900 ? LIBXML_PARSEHUGE : 0;
        $oldSetting = libxml_use_internal_errors(true);
        $result = simplexml_load_string($xml, null, $flags);
        $errors = $this->collectXmlErrors();
        libxml_use_internal_errors($oldSetting);
        if (!$result) {
            throw new \Exception('Problem loading XML: ' . $errors);
        }

        // If we got this far, we have a valid response:
        return $result;
    }
1307838
public static function cleanXML($xml)
    {
        if($xml != '') {
            $doc = new \DOMDocument();
            $doc->loadXML($xml);
            $doc->formatOutput = true;
            return $doc->saveXML();
        } else {
            return '';
        }
    }
1349405
protected static function _exportFile($xmlDocument, $file, $data)
    {
        $xmlFile = $xmlDocument->createElement('file');
        $xmlFile->setAttribute('name', $file);
        foreach ($data as $line => $node) {
            $xmlLine = $xmlDocument->createElement('line');
            $xmlLine->setAttribute('num', $line + 1);
            $xmlLine->setAttribute('type', 'stmt');
            $xmlLine->setAttribute('count', $data[$line]);
            $xmlFile->appendChild($xmlLine);
        }
        return $xmlFile;
    }
233757
public function formatXml($xml)
    {
        $dom = new DOMDocument();
        $dom->formatOutput = true;
        $dom->preserveWhiteSpace = false;
        $dom->loadXml($xml);

        return $dom->saveXml();
    }
1308200
protected static function loadXML($xml)
	{
		// Activate small nodes allocation and relax LibXML's hardcoded limits if applicable
		$flags = (LIBXML_VERSION >= 20700) ? LIBXML_COMPACT | LIBXML_PARSEHUGE : 0;

		$dom = new DOMDocument;
		$dom->loadXML($xml, $flags);

		return $dom;
	}