提取出xml数据包中的加密消息
@param string $xmltext 待提取的xml字符串
@return string 提取出的加密消息字符串
555289
public function extract($xmltext) {
        libxml_disable_entity_loader(true);
        try {
            $xml = new DOMDocument();
            $xml->loadXML($xmltext);
            $array_e    = $xml->getElementsByTagName('Encrypt');
            $array_a    = $xml->getElementsByTagName('ToUserName');
            $encrypt    = $array_e->item(0)->nodeValue;
            $tousername = $array_a->item(0)->nodeValue;
            return array(0, $encrypt, $tousername);
        } catch (Exception $e) {
            print $e . "\n";
            //return array(ErrorCode::$ParseXmlError, null, null);
        }
    }
623053
static function xmlData($string, $cdata=false) {
        $string = str_replace("]]>", "]]]]><![CDATA[>", $string);
        if (!$cdata)
            $string = "<![CDATA[$string]]>";
        return $string;
    }
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']
            );
        }
    }
1097116
static public function xmlToArray($xml)
    {
        //禁止引用外部xml实体
        libxml_disable_entity_loader(true);
        $values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
        return $values;
    }
965774
public function parseXml($xmlString)
    {
        $this->_entry->parseXml($xmlString);
        $content = $this->_entry->getContent();
        if (is_null($content)) {
            $this->_ruleDescription = null;
        } else {
            $this->_ruleDescription = RuleDescription::create($content->getText());
        }
    }
548936
public function xml_escape($string) {
        if (!empty($string) && htmlspecialchars($string) != $string) {
            // If the string contains something that looks like the end
            // of a CDATA section, then we need to avoid errors by splitting
            // the string between two CDATA sections.
            $string = str_replace(']]>', ']]]]><![CDATA[>', $string);
            return "<![CDATA[{$string}]]>";
        } else {
            return $string;
        }
    }
446349
public function fromXml(SimpleXMLElement $xmlElement)
    {
        $classname = $this->xmlElementToClassname($xmlElement);
        if (!is_null($classname)) {
            $return = new $classname();
            if ($return instanceof ArrayObject) {
                foreach ($xmlElement as $xmlChild) {
                    $return->append($this->fromXml($xmlChild));
                }
            } else {
                $objectData = array();
                foreach ($xmlElement as $xmlChild) {
                    $key = $this->xmlkeyToProperty($xmlChild->getName());
                    if (isset($objectData[$key])) {
                        if (!is_array($objectData[$key])) {
                            $objectData[$key] = array($objectData[$key]);
                        }
                        $objectData[$key][] = $this->fromXml($xmlChild);
                    } else {
                        $objectData[$key] = $this->fromXml($xmlChild);
                    }
                }
                $return->setData($objectData, false);
            }
        } else {
            $return = $this->castValue($xmlElement);
        }

        return $return;
    }
517606
public function parse($xmldom) : string
    {
        if (!$this->templatePreProcessed) {
            $this->preProcessTemplate();
        }

        $conversion = new Conversion($xmldom);
        $styles[0] = $this->getPreProcessedTemplateDom();
        $conversion->addStylesheet($styles);

        return (string) $conversion->toString();
    }
61277
public function processConvert($xmlString)
    {
        $result = [];

        if(true === $this->isXml($xmlString))
        {
            $iterator = new SimpleXmlIterator($xmlString);

            $result = $this->getArrayFromXml($iterator);
        }

        return $result;
    }
965020
private function plainXML($xmlRequest)
    {
        $envelope = new DOMDocument();
        $envelope->loadXML(
            '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
		    <soapenv:Body></soapenv:Body>
		</soapenv:Envelope>'
        );

        $envelope->encoding = 'UTF-8';
        $envelope->version = '1.0';
        $xmlRequestType = $xmlRequest->documentElement->localName;
        $xmlRequestTypeNode = $xmlRequest->getElementsByTagName($xmlRequestType)->item(0);
        $xmlRequestTypeNode = $envelope->importNode($xmlRequestTypeNode, true);

        $envelope->getElementsByTagName('Body')->item(0)->appendChild($xmlRequestTypeNode);

        return $envelope->saveXML();
    }
1301527
public function parseString($xmlString, $xmlFile = null)
    {
        // we don't want infinite recursion
        if ($this->isAlreadyParsed($xmlFile)) {
            return;
        }
        // store current schema file path
        $this->schemasTagsStack[$xmlFile] = [];
        $this->currentXmlFile = $xmlFile;

        $parser = xml_parser_create();
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        xml_set_object($parser, $this);
        xml_set_element_handler($parser, 'startElement', 'endElement');
        if (!xml_parse($parser, $xmlString)) {
            throw new SchemaException(sprintf('XML error: %s at line %d',
                xml_error_string(xml_get_error_code($parser)),
                xml_get_current_line_number($parser))
            );
        }
        xml_parser_free($parser);

        array_pop($this->schemasTagsStack);

        return $this->schema;
    }
5983
public static function newDocumentXML($markup = null, $charset = null) 
    {
        $contentType = $charset
        ? ";charset=$charset"
        : '';
        return self::newDocument($markup, "text/xml{$contentType}");
    }
279947
private function arrayToXml(array &$data, SimpleXMLElement $xmlData)
    {
        foreach ($data as $key => $value) {
            $key = ltrim($key, '_');

            if (\is_array($value)) {
                if (\is_numeric($key)) {
                    $key = 'resource';
                }

                if (false === empty($value[JsonTransformer::LINKS_HREF])) {
                    $subnode = $xmlData->addChild('link');
                    $subnode->addAttribute('rel', $key);

                    foreach ($this->linkKeys as $linkKey) {
                        if (!empty($value[$linkKey])) {
                            $subnode->addAttribute($linkKey, $value[$linkKey]);
                        }
                    }
                } else {
                    if (!empty($value[JsonTransformer::LINKS_KEY][JsonTransformer::LINK_SELF][JsonTransformer::LINKS_HREF])) {
                        $subnode = $xmlData->addChild('resource');
                        $subnode->addAttribute(
                            JsonTransformer::LINKS_HREF,
                            $value[JsonTransformer::LINKS_KEY][JsonTransformer::LINK_SELF][JsonTransformer::LINKS_HREF]
                        );

                        if ($key !== 'resource') {
                            $subnode->addAttribute('rel', $key);
                        }
                    } else {
                        $subnode = $xmlData->addChild($key);
                    }
                }

                $this->arrayToXml($value, $subnode);
            } else {
                if ($key !== JsonTransformer::LINKS_HREF) {
                    if ($value === true || $value === false) {
                        $value = ($value) ? 'true' : 'false';
                    }

                    $xmlData->addChild("$key", '<![CDATA['.html_entity_decode($value).']]>');
                }
            }
        }
    }
1265325
public static function unparse($xml)
	{
		if (isset(static::$beforeUnparse))
		{
			$xml = call_user_func(static::$beforeUnparse, $xml);
		}

		$text = Unparser::unparse($xml);

		if (isset(static::$afterUnparse))
		{
			$text = call_user_func(static::$afterUnparse, $text);
		}

		return $text;
	}
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;
    }
1054177
public function parseXml($xmlString)
    {
        $personXml = simplexml_load_string($xmlString);
        $personArray = (array) $personXml;

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

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

        if (array_key_exists('email', $personArray)) {
            $this->email = (string) $personArray['email'];
        }
    }
633092
protected function parserXml($xmlString)
    {
        libxml_disable_entity_loader(true);
        return json_decode(json_encode(simplexml_load_string($xmlString,'SimpleXMLElement', LIBXML_NOCDATA), true), true);
    }