For consistently, add commonly used starting and ending tags to input XML

@todo: $xml should be a property of the class (true OO style), then $this->addOuterTags();

@param $inputXml
@return string
540901
protected function addOuterTags($inputXml)
    {
        // start xml with encoding tag
        $finalXml = $this->xmlStart();
        
        // open script tag
        $finalXml .= "\n<script>";
        
        // include override of submit command if specified
        if ($this->getOption('sbmjobCommand')) {
            $sbmJobCommand = $this->getOption('sbmjobCommand');
            $finalXml .= "\n<sbmjob>{$sbmJobCommand}</sbmjob>";
        }
        
        // inner "meat" of the XML
        $finalXml .= "\n$inputXml";
        
        // close script tag
        $finalXml .= "\n</script>";
        
        return $finalXml; 
    }
534330
public function loadXml($xml)
    {
        if (is_string($xml)) {
            $this->xml = $xml = simplexml_load_string($xml);
        } elseif ($xml instanceof \SimpleXMLElement) {
            $this->xml = $xml;
        }

        $this->addFields($xml);

        return $this;
    }
909295
private function parseLocationInput (SimpleXMLElement $xml)
    {
        return (new ReflectionClass(Input\Location::class))->newInstanceArgs(
            array_merge(
                $this->getCommonMessageProperties($xml),
                [
                    [(double)$xml->Location_X, (double)$xml->Location_Y],
                    (double)$xml->Scale,
                    (string)$xml->Label,
                ]
            )
        );
    }
659228
public function createFromXml(XmlElement $xml): TrackInterface
    {
        $uri = (string) $xml->getTag("res");
        $class = $this->guessTrackClass($uri);

        return $class::createFromXml($xml, $this->controller);
    }
445345
public function Init($xml)
    {
        $this->FromXml($xml);
        //fix bug 2015-06-29
        if ($this->values['return_code'] != 'SUCCESS') {
            return $this->GetValues();
        }
        $this->CheckSign();
        return $this->GetValues();
    }
1032699
protected function buildDomDocumentFromXml($xml)
    {
        // see the following URL for this trick:
        // http://stackoverflow.com/questions/15223224/how-to-remove-all-namespaces-from-xml-in-php-tags-and-attributes

        $sxe     = new \SimpleXMLElement($xml);
        $dom_sxe = dom_import_simplexml($sxe);

        $dom     = new DOMDocument('1.0');
        $dom_sxe = $dom->importNode($dom_sxe, true);
        $dom->appendChild($dom_sxe);

        /** @var DOMElement $element */
        $element = $dom->childNodes->item(0);


        foreach ($sxe->getDocNamespaces(true) as $name => $uri) {

            $element->removeAttributeNS($uri, $name);
        }

        return $dom;
    }
1082663
private function parseTextInput (SimpleXMLElement $xml)
    {
        return (new ReflectionClass(Input\Text::class))->newInstanceArgs(
            array_merge(
                $this->getCommonMessageProperties($xml),
                [$xml->Content]
            )    
        );
    }
258669
public function xmlOverride($matches)
    {
        // this might just be an inequality, so we first need to disambiguate
        // that

        // 1.5 - the disambiguation is pretty simple, an XML tag must
        // follow either whitespace, (, or {, and the '<' must be followed
        // by '[!?_a-zA-Z]
        // I'm not sure if a comment is a special case, or if it's treated as
        // whitespace...
        $xml = false;
        for ($i = count($this->tokens) - 1; $i >= 0; $i--) {
            $tok = $this->tokens[$i];
            $name = $tok[0];
            // ... but we're going treat it as a no-op and skip over it
            if ($name === 'COMMENT') {
                continue;
            }
            $lastChar = $tok[1][strlen($tok[1]) - 1];
            if (!(ctype_space($lastChar) || $lastChar === '(' || $lastChar === '{')) {
                break;
            }
            if (!$this->check('/<[!?a-zA-Z0-9_]/')) {
                break;
            }
            $xml = true;
        }
        if (!$xml) {
            $this->record($matches[0], 'OPERATOR');
            $this->posShift(strlen($matches[0]));
            return;
        }
        $subscanner = new XmlScanner();
        $subscanner->string($this->string());
        $subscanner->pos($this->pos());
        $subscanner->xmlLiteral = true;
        $subscanner->init();
        $subscanner->main();
        $tagged = $subscanner->tagged();
        $this->record($tagged, 'XML', true);
        $this->pos($subscanner->pos());
    }
19728
protected function createTemplateFromXml($xml)
    {
        /** @var Template $template */
        $template = $this->serializer->deserialize($xml, 'phpDocumentor\Transformer\Template', 'xml');
        $template->propagateParameters();

        return $template;
    }
494451
public static function parseResponseConditionXml(SimpleXMLElement $xml){
        $returnValue = self::parseElementXml($xml);
        foreach($xml->responseIf as $responseIfXml){
            $returnValue['responseIf'] = self::parseResponseIfXml($responseIfXml);
            break;
        }
        foreach($xml->responseElseIf as $responseIfXml){
            if(!isset($returnValue['responseElseIfs'])){
                $returnValue['responseElseIfs'] = array();
            }
            $returnValue['responseElseIfs'][] = self::parseResponseIfXml($responseIfXml);
        }
        foreach($xml->responseElse as $responseIfXml){
            $returnValue['responseElse'] = self::parseResponseElseXml($responseIfXml);
            break;
        }
        return $returnValue;
    }
1164724
protected static function xmlToArray(\SimpleXMLElement $xml)/*# : array */
    {
        $arr = array();
        foreach ($xml as $element) {
            $tag = $element->getName();
            $ele = get_object_vars($element);
            if (!empty($ele)) {
                $arr[$tag] = $element instanceof \SimpleXMLElement ?
                    static::xmlToArray($element) :
                    $ele;
            } else {
                $arr[$tag] = trim($element);
            }
        }
        return $arr;
    }
964842
public function fromXml(\SimpleXMLElement $entryXml)
    {
        Validate::notNull($entryXml, 'entryXml');

        $this->attributes = (array) $entryXml->attributes();
        $entryArray = (array) $entryXml;

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

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

        if (array_key_exists('content', $entryArray)) {
            $content = new Content();
            $content->fromXml($entryArray['content']);
            $this->content = $content;
        }

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

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

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

        if (array_key_exists('published', $entryArray)) {
            $this->published = $entryArray['published'];
        }

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

        if (array_key_exists('source', $entryArray)) {
            $source = new Source();
            $source->parseXml($entryArray['source']->asXML());
            $this->source = $source;
        }

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

        if (array_key_exists('updated', $entryArray)) {
            $this->updated = \DateTime::createFromFormat(
                \DateTime::ATOM,
                (string) $entryArray['updated']
            );
        }
    }
310455
protected function sanitizeXml($xml)
    {
        // Sanitize the XML if requested:
        $newXML = trim(preg_replace($this->sanitizeRegex, ' ', $xml, -1, $count));

        if ($count > 0 && $this->badXmlLog) {
            $this->logBadXML($xml);
        }

        return $newXML;
    }
854812
public static function toSimpleXMLElement($xml)
    {
        if ($xml instanceof \SimpleXMLElement) {
            return $xml;
        }

        if ($xml instanceof \DOMDocument) {
            return simplexml_import_dom($xml);
        }

        if (is_string($xml)) {

            if (is_file($xml)) {
                return simplexml_load_file($xml);
            }

            return simplexml_load_string($xml);
        }

        $type = is_object($xml) ? get_class($xml) : gettype($xml);

        throw new \InvalidArgumentException("Cannot convert instance of '$type' to DOMDocument");
    }
1351702
public static function Init($xml)
    {
        $obj = new self();
        $obj->FromXml($xml);
        //fix bug 2015-06-29
        if($obj->values['return_code'] != 'SUCCESS'){
            return $obj->GetValues();
        }
        $obj->CheckSign();
        return $obj->GetValues();
    }
1217424
function inputXML()
    {
        $contentObjectAttribute = $this->ContentObjectAttribute;
        $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );

        $originalInput = 'originalInput_' . $contentObjectAttributeID;
        $isInputValid = 'isInputValid_' . $contentObjectAttributeID;

        if ( isset( $GLOBALS[$isInputValid] ) and $GLOBALS[$isInputValid] == false )
        {
            $output = $GLOBALS[$originalInput];
        }
        else
        {
            $dom = new DOMDocument( '1.0', 'utf-8' );
            $success = $dom->loadXML( $this->XMLData );

            $editOutput = new eZSimplifiedXMLEditOutput();
            $dom->formatOutput = true;
            if ( eZDebugSetting::isConditionTrue( 'kernel-datatype-ezxmltext', eZDebug::LEVEL_DEBUG ) )
                eZDebug::writeDebug( $dom->saveXML(), eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext', __METHOD__ . ' xml string stored in database' ) );
            $output = $editOutput->performOutput( $dom );
        }
        return $output;
    }
624227
public function assinarXML($xml, $tag, $ignoreValidCert = false)
    {
        $xmlDoc = new Dom();

        //Limpando o XML
        //$order = ["\r\n", "\n", "\r", "\t"];
        $order = ["\t"];
        $xml = str_replace($order, '', $xml);

        $xmlDoc->loadXMLString($xml);
        $node = $xmlDoc->getElementsByTagName($tag)->item(0);

        // Raiz
        $root = $xmlDoc->getElementsByTagName($tag)->item(0)->parentNode;

        $pkcs = new Pkcs12('', $this->getChavePub(), $this->getChavePri(), $this->getCertificado(), $ignoreValidCert);

        // Assinando
        $objSSLPriKey = openssl_get_privatekey($this->chavePri);
        $sxml = $pkcs->zSignXML($xmlDoc, $root, $node, $objSSLPriKey);

        return $sxml;
    }