*
@param $str_xml
@return PagSeguroInstallment
2441
public static function readInstallments($str_xml)
    {

        // Parser
        $parser = new PagSeguroXmlParser($str_xml);
        
        
        // <installment>
        $data = $parser->getResult('installments');
        
        
        // <installment><installments>
        if (isset($data)) {
            if (isset($data["installment"][0])) {
                foreach ($data["installment"] as $installment) {
                    $installments[] = new PagSeguroInstallment(
                        $installment['cardBrand'],
                        $installment['quantity'],
                        $installment['amount'],
                        $installment['totalAmount'],
                        $installment['interestFree']
                    );
                }
            } else {
                    $installments[] = new PagSeguroInstallment(
                        $data["installment"]['cardBrand'],
                        $data["installment"]['quantity'],
                        $data["installment"]['amount'],
                        $data["installment"]['totalAmount'],
                        $data["installment"]['interestFree']
                    );
            }
            $installments = new PagSeguroInstallments($installments);
            return $installments;
        }
    }
83476
final public function deserializeXml($xmlstr)
    {
        try {
            $element = new \SimpleXMLElement($xmlstr);
        } catch (\Exception $ex) {
            return false;
        }
        foreach ($element as $name => $value) {
            $this->$name = stripslashes(urldecode(htmlspecialchars_decode($value)));
        }

        return true;
    }
1111414
def ObtenerTagXml(self, *tags):
        ""
        # convierto el xml a un objeto
        try:
            if self.xml:
                xml = self.xml
                # por cada tag, lo busco segun su nombre o posición
                for tag in tags:
                    xml = xml(tag) # atajo a getitem y getattr
                # vuelvo a convertir a string el objeto xml encontrado
                return str(xml)
        except Exception, e:
            self.Excepcion = u"%s" % (e)
57475
private function sanitizeEscapedText($str)
    {
        $str = str_replace('&apos;', '&#39;', $str); // PHP's html_entity_decode doesn't seem to support that!

        /* <?php ?> blocks can't reliably work in attributes (due to escaping impossible in XML)
           so they have to be converted into special TALES expression
        */
        $types = version_compare(PHP_VERSION, '5.4.0') < 0 ? (ini_get('short_open_tag') ? 'php|=|' : 'php') : 'php|=';
        $str = preg_replace_callback("/<\?($types)(.*?)\?>/", array('self', 'convertPHPBlockToTALES'), $str);

        // corrects all non-entities and neutralizes potentially problematic CDATA end marker
        $str = strtr(preg_replace('/&(?!(?:#x?[a-f0-9]+|[a-z][a-z0-9]*);)/i', '&amp;', $str), array('<'=>'&lt;', ']]>'=>']]&gt;'));

        return $str;
    }
1061440
public function loadXML($xml_data)
    {
        $this->xml_data = $xml_data;
        $this->xml = new \sasco\LibreDTE\XML();
        if (!$this->xml->loadXML($this->xml_data)) {
            return false;
        }
        $this->toArray();
        return $this->xml;
    }
1275421
public static function webappPrefixTooShort(string $str)
    {
        $length = strlen($str);
        if ($length === 0) {
            return new self(sprintf(
                'The WebApp Prefix must be at least 3 characters. You supplied an empty Prefix.'
            ));
        } else {
            return new self(sprintf(
                'The WebApp Prefix must be at least 3 characters. You supplied a %s character Prefix: %s',
                $length,
                $str
            ));
        }
    }
591144
public function svg($str_filename = null)
    {
        $str_svg = $this->svgForHtml5();
        $str_svg = '<?xml version="1.0" encoding="utf-8"?>'. "\n". $str_svg;

        if (!is_null($str_filename)) {
            file_put_contents($str_filename, $str_svg);
        }

        return $str_svg;
    }
48245
public static function readSearchResult($str_xml)
    {
        // Parser
        $parser = new PagSeguroXmlParser($str_xml);

        $authorization = new PagSeguroAuthorizationSearchResult();

        // <authorizationSearchResult>
        $data = $parser->getResult('authorizationSearchResult');

        // <authorizationSearchResult><date>
        if (isset($data["date"])) {
            $authorization->setDate($data['date']);
        }

        //<authorizationSearchResult><authorizations><authorization>
        if (isset($data['authorizations']) && is_array($data['authorizations'])) {
            if (isset($data['authorizations']['authorization'])
                && $data["resultsInThisPage"] > 1) {
                $i = 0;
                foreach ($data['authorizations']['authorization'] as $key => $value) {
                    $newAuthorization = new PagSeguroAuthorization();
                    $nAuthorization[$i++] = self::buildAuthorization($newAuthorization, $value);
                }
                $authorization->setAuthorizations($nAuthorization);

            } else {
                $newAuthorization = new PagSeguroAuthorization();
                $authorization->setAuthorizations(
                    self::buildAuthorization(
                        $newAuthorization,
                        $data['authorizations']['authorization']
                    )
                );
            }

        }

        // <authorizationSearchResult><resultsInThisPage>
        if (isset($data["resultsInThisPage"])) {
            $authorization->setResultsInThisPage($data['resultsInThisPage']);
        }
        // <authorizationSearchResult><totalPages>
        if (isset($data["totalPages"])) {
            $authorization->setTotalPages($data['totalPages']);
        }
        // <authorizationSearchResult><currentPage>
        if (isset($data["currentPage"])) {
            $authorization->setCurrentPage($data["currentPage"]);
        }

        return $authorization;
    }
925330
public static function createByXml(\SimpleXMLElement $xml, \SplPriorityQueue $namespaces = null)
    {
        $type = (string) XmlHelper::get($xml, 'type', 'text');

        if (class_exists($type)) {
            $class = $type;
        } else {
            $class = (string) static::findFieldClass($type, $namespaces);
        }

        if (!class_exists($class)) {
            // Fallback to TextField
            $class = static::$defaultNamespace . '\\TextField';
        }

        return new $class($xml);
    }
1204064
public function reply($str)
    {
        $message = new \sb\XMPP\Message();
        $message->setTo($this->getFrom());
        $message->setFrom($this->getTo());
        $message->setBody($str);
        $this->client->sendMessage($message);
    }
152639
public static function import(SimpleXMLElement $pk)
    {
        if ($pk['package']) {
            $app = Application::getFacadeApplication();
            $pkg = $app->make(PackageService::class)->getByHandle($pk['package']);
        } else {
            $pkg = null;
        }

        return self::add(
            $pk['category'],
            $pk['handle'],
            $pk['name'],
            $pk['description'],
            $pk['can-trigger-workflow'] ? 1 : 0,
            $pk['has-custom-class'] ? 1 : 0,
            $pkg
        );
    }
1159653
public function toXmlElement(SimpleXMLElement $parentElement = null)
    {
        if ($parentElement === null) {
            throw new UserMessageException(t('The sitemap XML link should not be the first element.'));
        }
        if ($this->isSkip()) {
            $result = null;
        } else {
            $result = $parentElement->addChild('link', null, static::MULTILINGUAL_NAMESPACE);
            $result->addAttribute('rel', 'alternate');
            $result->addAttribute('hreflang', $this->getFinalHrefLang());
            $result->addAttribute('href', (string) $this->getUrl());
        }

        return $result;
    }
379643
public static function lstrip($str, $prefix)
    {
        if (substr($str, 0, strlen($prefix)) == $prefix) {
            return substr($str, strlen($prefix));
        }
        return $str;
    }
690745
public function prepend($str)
    {
        $value = $this->val();
        $this->val($str . $value);

        return $this;
    }
921103
private function getRootForUser()
	{
		$melisEngineTree = $this->serviceLocator->get('MelisEngineTree');
		$melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
		$melisCmsRights = $this->getServiceLocator()->get('MelisCmsRights');

		// Get the rights of the user
		$xmlRights = $melisCoreAuth->getAuthRights();
		$rightsObj = simplexml_load_string($xmlRights);

		$rootPages = array();
		$breadcrumbRightPages = array();

		// Loop into page ids of the rights to determine what are the root pages
		// Deleting possible doublons with parent pages selected and also children pages

		$sectionId = MelisCmsRightsService::MELISCMS_PREFIX_PAGES;
		if (empty($rightsObj->$sectionId))
			return array();

		foreach ($rightsObj->$sectionId->id as $rightsPageId)
		{
			$rightsPageId = (int)$rightsPageId;

			// No need to continue, -1 is root, there's a full access
			if ($rightsPageId == -1)
				return array(-1);

			// Get the breadcrumb of the page and reformat it to a more simple array
			$breadcrumb = $melisEngineTree->getPageBreadcrumb($rightsPageId, 0, true);
			$breadcrumb = $this->cleanBreadcrumb($breadcrumb);


			/**
			 * Looping on the temporary array holding pages
			 * Making intersection to compare between the one checked and those already saved
			 * If the one checked is equal with the intersection, it means the one checked contains
			 * already the older one, the page is on top, then we will only keep this one and delete
			 * the old one
			 * Otherwise we save
			 */
			$add = true;
			for ($i = 0; $i < count($breadcrumbRightPages); $i++)
			{
				$result = array_intersect($breadcrumb, $breadcrumbRightPages[$i]);
				if ($result === $breadcrumb)
				{
					$add = false;
					$breadcrumbRightPages[$i] = $breadcrumb;
					break;
				}
				if ($result === $breadcrumbRightPages[$i])
				{
					$add = false;
					break;
				}
			}

			if ($add)
				$breadcrumbRightPages[count($breadcrumbRightPages)] = $breadcrumb;
		}

		/**
		 * Reformat final result to a simple array with the ids of pages
		 */
		foreach ($breadcrumbRightPages as $breadcrumbPage)
		{
			if (count($breadcrumbPage) > 0)
				array_push($rootPages, $breadcrumbPage[count($breadcrumbPage) - 1]);
		}

		return $rootPages;
	}
906975
public function addContent($str, $index = null)
    {
        if (!is_null($index)) {
            $this->contents[$index] = $str;
        } else {
            $this->contents[] = $str;
        }
        return $this;
    }
1233329
public static function &createXML($node_name, $arr = array()) {
        $xml = self::getXMLRoot();
        $xml->appendChild(self::convert($node_name, $arr));

        self::$xml = null;    // clear the xml node in the class for 2nd time use.
        return $xml;
    }