Serializes builder information into XML

@param DOMDocument $xml XML instance
@param BaseBuilder $builder Request builder
@param bool $isCheck If payment method is ACH

@return DOMElement
493286
protected function hydrateHolder(DOMDocument $xml, BaseBuilder $builder, $isCheck = false)
    {
        $holder = $xml->createElement($isCheck ? 'ConsumerInfo' : 'CardHolderData');

        if ($isCheck && $builder->paymentMethod instanceof RecurringPaymentMethod) {
            return null;
        }
        
        if ($builder->billingAddress !== null) {
            $holder->appendChild(
                $xml->createElement($isCheck ? 'Address1' : 'CardHolderAddr', $builder->billingAddress->streetAddress1)
            );
            $holder->appendChild(
                $xml->createElement($isCheck ? 'City' : 'CardHolderCity', $builder->billingAddress->city)
            );
            $holder->appendChild(
                $xml->createElement($isCheck ? 'State' : 'CardHolderState', $builder->billingAddress->getProvince())
            );
            $holder->appendChild(
                $xml->createElement($isCheck ? 'Zip' : 'CardHolderZip', $builder->billingAddress->postalCode)
            );
        }

        $propertyName = $isCheck ? 'checkHolderName' : 'cardHolderName';
        if (!empty($builder->paymentMethod->{$propertyName})) {
            $names = explode(' ', $builder->paymentMethod->{$propertyName}, 2);
            $holder->appendChild(
                $xml->createElement($isCheck ? 'FirstName' : 'CardHolderFirstName', $names[0])
            );

            if (isset($names[1])) {
                $holder->appendChild(
                    $xml->createElement($isCheck ? 'LastName' : 'CardHolderLastName', $names[1])
                );
            }
        }

        if ($isCheck) {
            if ($builder->paymentMethod->checkHolderName !== null) {
                $holder->appendChild($xml->createElement('CheckName', $builder->paymentMethod->checkHolderName));
            }

            if ($builder->paymentMethod->phoneNumber !== null) {
                $holder->appendChild($xml->createElement('PhoneNumber', $builder->paymentMethod->phoneNumber));
            }

            if ($builder->paymentMethod->driversLicenseNumber !== null) {
                $holder->appendChild($xml->createElement('DLNumber', $builder->paymentMethod->driversLicenseNumber));
            }

            if ($builder->paymentMethod->driversLicenseState !== null) {
                $holder->appendChild($xml->createElement('DLState', $builder->paymentMethod->driversLicenseState));
            }

            if ($builder->paymentMethod->ssnLast4 !== null
                || $builder->paymentMethod->birthYear !== null
            ) {
                $identity = $xml->createElement('IdentityInfo');
                $identity->appendChild($xml->createElement('SSNL4', $builder->paymentMethod->ssnLast4));
                $identity->appendChild($xml->createElement('DOBYear', $builder->paymentMethod->birthYear));
                $holder->appendChild($identity);
            }
        }

        return $holder;
    }
675021
public function toXML(DOMElement $parent) : DOMElement
    {
        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:X509Data');
        $parent->appendChild($e);

        /** @var \SAML2\XML\Chunk|\SAML2\XML\ds\X509Certificate $n */
        foreach ($this->getData() as $n) {
            $n->toXML($e);
        }

        return $e;
    }
878068
public static function isValidXmlFragment($xml, $doc = null)
    {
        if ($doc == null) {
            $doc = new DOMDocument("1.0", "ISO-8859-1");
        }

        $fragment = $doc->createDocumentFragment();
        @$fragment->appendXML($xml);
        $node = @$doc->appendChild($fragment);

        return $node !== false;
    }
485882
public function setXSL($xsl, $isFile = false)
    {
        $this->_xsl = ($isFile ? file_get_contents($xsl) : $xsl);
    }
1239687
private function buildXmlFile($parentXmlElement, $file, $directoryRealPath)
    {
        $xmlFile = $parentXmlElement->addChild('file');
        $xmlFile->addAttribute('name', $file);
        $xmlFile->addAttribute('hash', md5_file($directoryRealPath . '/' . $file));

        return $this;
    }
635349
public function toXML(DOMElement $parent) : DOMElement
    {
        $e = $parent->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:SubjectConfirmationData');
        $parent->appendChild($e);

        if ($this->NotBefore !== null) {
            $e->setAttribute('NotBefore', gmdate('Y-m-d\TH:i:s\Z', $this->NotBefore));
        }
        if ($this->NotOnOrAfter !== null) {
            $e->setAttribute('NotOnOrAfter', gmdate('Y-m-d\TH:i:s\Z', $this->NotOnOrAfter));
        }
        if ($this->Recipient !== null) {
            $e->setAttribute('Recipient', $this->Recipient);
        }
        if ($this->InResponseTo !== null) {
            $e->setAttribute('InResponseTo', $this->InResponseTo);
        }
        if ($this->Address !== null) {
            $e->setAttribute('Address', $this->Address);
        }
        /** @var \SAML2\XML\ds\KeyInfo|\SAML2\XML\Chunk $n */
        foreach ($this->getInfo() as $n) {
            $n->toXML($e);
        }

        return $e;
    }
1264609
public function toXML(DOMElement $parent) : DOMElement
    {
        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Constants::NS_MD, 'md:ContactPerson');
        $parent->appendChild($e);

        $e->setAttribute('contactType', $this->getContactType());

        foreach ($this->getContactPersonAttributes() as $attr => $val) {
            $e->setAttribute($attr, $val);
        }

        Extensions::addList($e, $this->getExtensions());

        if ($this->Company !== null) {
            Utils::addString($e, Constants::NS_MD, 'md:Company', $this->Company);
        }
        if ($this->GivenName !== null) {
            Utils::addString($e, Constants::NS_MD, 'md:GivenName', $this->GivenName);
        }
        if ($this->SurName !== null) {
            Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
        }
        if (!empty($this->getEmailAddress())) {
            Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', false, $this->getEmailAddress());
        }
        if (!empty($this->getTelephoneNumber())) {
            Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', false, $this->getTelephoneNumber());
        }

        return $e;
    }
114890
public function toXML(DOMNode $parentElement = null) : DOMElement
    {
        if ($parentElement === null) {
            $document = DOMDocumentFactory::create();
            $parentElement = $document;
        } else {
            $document = $parentElement->ownerDocument;
        }

        $root = $document->createElementNS(Constants::NS_SAML, 'saml:'.'EncryptedAssertion');
        $parentElement->appendChild($root);

        $root->appendChild($document->importNode($this->encryptedData, true));

        return $root;
    }
556691
public function encryptAndSign($bizContent, $rsaPublicKeyPem, $rsaPrivateKeyPem, $charset, $isEncrypt, $isSign, $signType='RSA') {
		// 加密，并签名
		if ($isEncrypt && $isSign) {
			$encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);
			$sign = $this->sign($encrypted, $signType);
			$response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>RSA</encryption_type><sign>$sign</sign><sign_type>$signType</sign_type></alipay>";
			return $response;
		}
		// 加密，不签名
		if ($isEncrypt && (!$isSign)) {
			$encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);
			$response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>$signType</encryption_type></alipay>";
			return $response;
		}
		// 不加密，但签名
		if ((!$isEncrypt) && $isSign) {
			$sign = $this->sign($bizContent, $signType);
			$response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$bizContent</response><sign>$sign</sign><sign_type>$signType</sign_type></alipay>";
			return $response;
		}
		// 不加密，不签名
		$response = "<?xml version=\"1.0\" encoding=\"$charset\"?>$bizContent";
		return $response;
	}
1186850
public function _hydrateAdditionalTxnFields($details, DOMDocument $xml)
    {
        $additionalTxnFields = $xml->createElement('hps:AdditionalTxnFields');

        if ($details->memo != null && $details->memo != "") {
            $additionalTxnFields->appendChild($xml->createElement('hps:Description', $details->memo));
        }

        if ($details->invoiceNumber != null && $details->invoiceNumber != "") {
            $additionalTxnFields->appendChild($xml->createElement('hps:InvoiceNbr', $details->invoiceNumber));
        }

        if ($details->customerId != null && $details->customerId != "") {
            $additionalTxnFields->appendChild($xml->createElement('hps:CustomerID', $details->customerId));
        }

        return $additionalTxnFields;
    }
1315789
public static function convertFromXMLString($root_element, $xml)
    {
        $doc = new DOMDocument('1.0', 'utf-8');
        $doc->loadXML($xml);

        return self::convertFromDOMDocument($root_element, $doc);
    }
159663
public function xml(SimpleXMLElement $parent)
    {
        $command = $parent->addChild('command');
        $command->addAttribute('name', $this->_name);
        $command->addAttribute('help', $this->_help);

        return $parent;
    }
1162766
public function toXml(\SimpleXMLElement $root) {
    	$propertyNode = $root->addChild("property");
    	$propertyNode->addAttribute("name", $this->getName());
    	$commentNode = $propertyNode->addChild("comment");
    	
    	$node= dom_import_simplexml($commentNode);
   		$no = $node->ownerDocument;
   		$node->appendChild($no->createCDATASection($this->getDocComment())); 
    	
    	
		$propertyNode->addAttribute("modifier", $this->isPrivate() ? 'private' : $this->isProtected() ? "protected" : "public");
		$propertyNode->addAttribute("is_static", $this->isStatic() ? "true" : "false");
		
    	
    	if ($this->isPublic() && !$this->isStatic()) {
	    	// Default value
	    	$className = $this->refClass->getName();
	    	/*$instance = new $className();
			$property = $this->getName();;
	
			$propertyNode->addChild("default", serialize($instance->$property));*/
			$propertyNode->addChild("default", serialize($this->getDefault()));
    	}    	
    }
748668
public function toXML(DOMElement $parent) : ?DOMElement
    {
        $e = null;
        if (!empty($this->DisplayName)
         || !empty($this->Description)
         || !empty($this->InformationURL)
         || !empty($this->PrivacyStatementURL)
         || !empty($this->Keywords)
         || !empty($this->Logo)
         || !empty($this->children)
        ) {
            $doc = $parent->ownerDocument;

            $e = $doc->createElementNS(Common::NS, 'mdui:UIInfo');
            $parent->appendChild($e);

            Utils::addStrings($e, Common::NS, 'mdui:DisplayName', true, $this->DisplayName);
            Utils::addStrings($e, Common::NS, 'mdui:Description', true, $this->Description);
            Utils::addStrings($e, Common::NS, 'mdui:InformationURL', true, $this->InformationURL);
            Utils::addStrings($e, Common::NS, 'mdui:PrivacyStatementURL', true, $this->PrivacyStatementURL);

            foreach ($this->Keywords as $child) {
                $child->toXML($e);
            }

            foreach ($this->Logo as $child) {
                $child->toXML($e);
            }

            foreach ($this->children as $child) {
                $child->toXML($e);
            }
        }

        return $e;
    }
855606
public static function getXML($data, $isFile = true)
	{
		// Disable libxml errors and allow to fetch error information as needed
		libxml_use_internal_errors(true);

		if ($isFile)
		{
			// Try to load the XML file
			$xml = simplexml_load_file($data);
		}
		else
		{
			// Try to load the XML string
			$xml = simplexml_load_string($data);
		}

		return $xml;
	}
493308
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'familyCode',
            FamilySelectorType::class,
            [
                'label' => false,
                'placeholder' => 'permission.family.placeholder',
                'horizontal_input_wrapper_class' => 'col-sm-12',
            ]
        );
        foreach (FamilyPermission::getPermissions() as $permission) {
            $builder->add(
                $permission,
                CheckboxType::class,
                [
                    'widget_checkbox_label' => 'widget',
                    'horizontal_input_wrapper_class' => 'col-sm-1',
                ]
            );
        }

        $builder->get('familyCode')->addModelTransformer(
            new CallbackTransformer(
                function ($originalData) {
                    if (null === $originalData) {
                        return null;
                    }
                    // Ignoring missing family
                    if (!$this->familyRegistry->hasFamily($originalData)) {
                        return null;
                    }

                    return $this->familyRegistry->getFamily($originalData);
                },
                function ($submittedData) {
                    if ($submittedData instanceof FamilyInterface) {
                        return $submittedData->getCode();
                    }

                    return $submittedData;
                }
            )
        );
    }
489496
public static function createFromXml(SimpleXMLElement $xmlRecipient)
    {
        $recipient = new DTO\Recipient();

        if (isset($xmlRecipient->Nm)) {
            $recipient->setName((string) $xmlRecipient->Nm);
        }
        if (isset($xmlRecipient->PstlAdr)) {
            $recipient->setAddress(Address::createFromXml($xmlRecipient->PstlAdr));
        }
        if (isset($xmlRecipient->CtryOfRes)) {
            $recipient->setCountryOfResidence((string) $xmlRecipient->CtryOfRes);
        }
        if (isset($xmlRecipient->CtctDtls)) {
            $recipient->setContactDetails(ContactDetails::createFromXml($xmlRecipient->CtctDtls));
        }
        if (isset($xmlRecipient->Id)) {
            if (isset($xmlRecipient->Id->OrgId)) {
                $recipient->setIdentification(OrganisationIdentification::createFromXml($xmlRecipient->Id->OrgId));
            }
        }

        return $recipient;
    }