Creates a generator instance with specified XML string.

@param string $xmlString A string representing a generator
instance
179006
public function parseXml($xmlString)
    {
        $generatorXml = new \SimpleXMLElement($xmlString);
        $attributes = $generatorXml->attributes();
        if (!empty($attributes['uri'])) {
            $this->uri = (string) $attributes['uri'];
        }

        if (!empty($attributes['version'])) {
            $this->version = (string) $attributes['version'];
        }

        $this->text = (string) $generatorXml;
    }
514029
public function validateXml(string $xmlString): Asserts
    {
        return $this->validate($xmlString, XmlNodeUtils::nodeFromXmlString($xmlString));
    }
1061468
public function convert($xmlString) {

        $dom = new \DOMDocument ();
        $dom->loadXML($xmlString);

        $documentElement = $dom->documentElement;
        return $documentElement ? $this->convertDOM($dom->documentElement) : $xmlString;
    }
101695
public function writeString($string)
    {
        fwrite($this->sharedStringsFilePointer, '<si><t xml:space="preserve">' . $this->stringsEscaper->escape($string) . '</t></si>');
        $this->numSharedStrings++;

        // Shared string ID is zero-based
        return ($this->numSharedStrings - 1);
    }
453235
public static function create($filterXmlString)
    {
        $filterXml = simplexml_load_string($filterXmlString);
        $attributes = (array) $filterXml->attributes();

        if (array_key_exists('i:type', $attributes)) {
            $type = (string) $attributes['i:type'];
            if ($type === 'TrueFilter') {
                return new TrueFilter();
            }

            if ($type === 'FalseFilter') {
                return new FalseFilter();
            }

            return new self();
        }

        return null;
    }
1245568
protected function getEntryList($xmlString)
    {
        $xml = simplexml_load_string($xmlString);

        if ($xml->getName() == Resources::ENTRY) {
            $entry = new Entry();
            $entry->fromXml($xml);
            $entries = [$entry];
        } else {
            $feed = new Feed();
            $feed->parseXml($xmlString);
            $entries = $feed->getEntry();
        }

        $result = [];
        if (is_array($entries)) {
            foreach ($entries as $entry) {
                $properties = $this->getPropertiesFromAtomEntry($entry);
                if (!empty($properties)) {
                    $result[] = $properties;
                }
            }
        }

        return $result;
    }
1105636
public void loadExampleStatementsFromXMLString(String xmlString) 
    		throws JSONException, IllegalArgumentException, JsonParseException, JsonMappingException, IOException
    {
    	if (LOGGER.isTraceEnabled()) {
    		LOGGER.trace("Receiving json string: " + xmlString);
    	}
    	JSONObject jsonobject = XML.toJSONObject(xmlString);
    	String[] root = JSONObject.getNames(jsonobject);
    	if (null == root) {
    		throw new IllegalArgumentException("no root object in xml found");
    	}
    	if (root.length > 1) {
    		throw new IllegalArgumentException("more than one root objects found");
    	}
    	JSONObject statement = jsonobject.getJSONObject(root[0]);
    	loadExampleStatementsFromJsonString(statement.toString());
    }
985906
protected function processReport($xmlString)
    {
        $xml = simplexml_load_string($xmlString);

        if ($xml === false) {
            $this->phpci->log($xmlString);
            throw new \Exception(Lang::get('could_not_process_report'));
        }

        $warnings = 0;
        foreach ($xml->duplication as $duplication) {
            foreach ($duplication->file as $file) {
                $fileName = (string)$file['path'];
                $fileName = str_replace($this->phpci->buildPath, '', $fileName);

                $message = <<<CPD
Copy and paste detected:

```
{$duplication->codefragment}
```
CPD;

                $this->build->reportError(
                    $this->phpci,
                    'php_cpd',
                    $message,
                    BuildError::SEVERITY_NORMAL,
                    $fileName,
                    $file['line'],
                    (int) $file['line'] + (int) $duplication['lines']
                );
            }

            $warnings++;
        }

        return $warnings;
    }
64464
public function parseXml($xmlString)
    {
        $this->_entry->parseXml($xmlString);
        $content = $this->_entry->getContent();
        if (is_null($content)) {
            $this->_topicDescription = null;
        } else {
            $this->_topicDescription = TopicDescription::create($content->getText());
        }
    }
1281710
protected function generateXMLObject($xml)
    {
        try {
            libxml_use_internal_errors(true);
            return new SimpleXMLElement($xml, LIBXML_NOCDATA);
        } catch (\Exception $e) {
            return false;
        }
    }
746044
public static function innerXML(\DOMNode $node, $xmlstring)
    {
        $xmlstring = str_replace("<br>", "<br/>", $xmlstring);
        $len = strlen($xmlstring);
        $endText = "";
        $close = strrpos($xmlstring, '>');
        if ($close !== false && $close < $len - 1) {
            $endText = substr($xmlstring, $close + 1);
            $xmlstring = substr($xmlstring, 0, $close + 1);
        }
        $open = strpos($xmlstring, '<');
        if ($open === false) {
            $node->nodeValue .= $xmlstring;
        } else {
            if ($open > 0) {
                $text = substr($xmlstring, 0, $open);
                $xmlstring = substr($xmlstring, $open);
                $node->nodeValue .= $text;
            }
            $dom = XmlUtil::getOwnerDocument($node);
            $xmlstring = "<rootxml>$xmlstring</rootxml>";
            $sxe = @simplexml_load_string($xmlstring);
            if ($sxe === false) {
                throw new XmlUtilException("Cannot load XML string.", 252);
            }
            $domSimpleXml = dom_import_simplexml($sxe);
            if (!$domSimpleXml) {
                throw new XmlUtilException("XML Parsing error.", 253);
            }
            $domSimpleXml = $dom->importNode($domSimpleXml, true);
            $childs = $domSimpleXml->childNodes->length;
            for ($i = 0; $i < $childs; $i++) {
                $node->appendChild($domSimpleXml->childNodes->item($i)->cloneNode(true));
            }
        }
        if (!empty($endText) && $endText != "") {
            $textNode = $dom->createTextNode($endText);
            $node->appendChild($textNode);
        }
        return $node->firstChild;
    }
1186693
public function formatXmlString($xmlString)
    {
        if(true === $this->isXml($xmlString))
        {
            $dom = new \DOMDocument;
            $dom->preserveWhiteSpace = false;
            $dom->loadXML($xmlString);
            $dom->formatOutput = true;

            return $dom->saveXml();
        }
        else
        {
            throw new InvalidArgumentException('Incorrect XML string');
        }
    }
226922
function xmlString()
    {
        $doc = new DOMDocument( '1.0', 'utf-8' );
        $root = $doc->createElement( "ezmultioption2" );
        $doc->appendChild( $root );


        $this->createDomElementForGroup( $doc, $root );

        $rulesNode = $doc->createElement( "rules" );

        foreach ( $this->Rules as $ruleFor => $rule )
        {
            unset( $ruleNode );
            $ruleNode = $doc->createElement( "rule" );
            $ruleNode->setAttribute( "option_id", $ruleFor );
            foreach ( $rule as $multioptionID => $ruleData )
            {
                unset( $ruleDataNode );
                $ruleDataNode = $doc->createElement( "rule_data" );
                $ruleDataNode->setAttribute( "multioption_id", $multioptionID );
                foreach ( $ruleData as $optionID )
                {
                    unset( $includeNode );
                    $includeNode = $doc->createElement( "option_id", $optionID );
                    $ruleDataNode->appendChild( $includeNode );
                }
                $ruleNode->appendChild( $ruleDataNode );
            }
            $rulesNode->appendChild( $ruleNode );
        }
        $root->appendChild( $rulesNode );

        $xml = $doc->saveXML();
        return $xml;
    }
1096275
public function apply(&$templateString) {

		$templateString = preg_replace_callback(
			'~<(\w+)\s+(.*?)class=(\'|")?([a-z0-9_]*\s*)shortened_(\d+)(.*?)>(?s)(.*?)(?-s)</\s*\1>~i',
			function($matches) {
				$prefix = sprintf("<%s %sclass=%s%sshortened%s>", $matches[1], $matches[2], $matches[3], $matches[4], $matches[6]);
				$suffix = sprintf("</%s>", $matches[1]);
				$len = (int) $matches[5];
				$src = $matches[7];
				
				if(strlen(strip_tags($src)) <= $len) {
					return $prefix . $src . $suffix;
				}
				
				$ret = substr(strip_tags($src), 0, $len + 1);
				return $prefix . substr($ret,0,strrpos($ret,' ')) . '&hellip;' . $suffix;
			},
			$templateString
		);

	}
1046213
function xmlString( )
    {
        $doc = new DOMDocument( '1.0', 'utf-8' );

        $root = $doc->createElement( "ezoption" );
        $doc->appendChild( $root );

        $name = $doc->createElement( "name" );
        $name->appendChild( $doc->createCDATASection( $this->Name ) );
        $root->appendChild( $name );

        $options = $doc->createElement( "options" );
        $root->appendChild( $options );

        foreach ( $this->Options as $option )
        {
            $optionNode = $doc->createElement( "option" );
            $optionNode->appendChild( $doc->createCDATASection( $option["value"] ) );
            $optionNode->setAttribute( "id", $option['id'] );
            $optionNode->setAttribute( 'additional_price', $option['additional_price'] );
            $options->appendChild( $optionNode );
        }

        $xml = $doc->saveXML();

        return $xml;
    }
52138
public function parseXml($xmlString)
    {
        $sourceXml = new \SimpleXMLElement($xmlString);
        $sourceArray = (array) $sourceXml;

        if (array_key_exists(Resources::AUTHOR, $sourceArray)) {
            $this->author = $this->processAuthorNode($sourceArray);
        }

        if (array_key_exists(Resources::CATEGORY, $sourceArray)) {
            $this->category = $this->processCategoryNode($sourceArray);
        }

        if (array_key_exists(Resources::CONTRIBUTOR, $sourceArray)) {
            $this->contributor = $this->processContributorNode($sourceArray);
        }

        if (array_key_exists('generator', $sourceArray)) {
            $generator = new Generator();
            $generator->setText((string) $sourceArray['generator']->asXML());
            $this->generator = $generator;
        }

        if (array_key_exists('icon', $sourceArray)) {
            $this->icon = (string) $sourceArray['icon'];
        }

        if (array_key_exists('id', $sourceArray)) {
            $this->id = (string) $sourceArray['id'];
        }

        if (array_key_exists(Resources::LINK, $sourceArray)) {
            $this->link = $this->processLinkNode($sourceArray);
        }

        if (array_key_exists('logo', $sourceArray)) {
            $this->logo = (string) $sourceArray['logo'];
        }

        if (array_key_exists('rights', $sourceArray)) {
            $this->rights = (string) $sourceArray['rights'];
        }

        if (array_key_exists('subtitle', $sourceArray)) {
            $this->subtitle = (string) $sourceArray['subtitle'];
        }

        if (array_key_exists('title', $sourceArray)) {
            $this->title = (string) $sourceArray['title'];
        }

        if (array_key_exists('updated', $sourceArray)) {
            $this->updated = \DateTime::createFromFormat(
                \DateTime::ATOM,
                (string) $sourceArray['updated']
            );
        }
    }
729649
static public function xml2array($xmlstring) 
    {
        $xml = simplexml_load_string($xmlstring);
        $json = json_encode($xml);

        return json_decode($json, true);
    }