Builds a UserActivities object from XML.

@param \DomDocument $xml
The xml tree containing the user activities.

@return UserActivities
A UserActivities object.
763064
public static function fromXml(\DOMDocument $xml)
    {
        $static = new static();

        $loans = $xml->getElementsByTagName('loan');
        $static->loans = LoanCollection::fromXml($loans);

        $loanHistory = $xml->getElementsByTagName('loanHistory');
        $static->loanHistory = LoanCollection::fromXml($loanHistory);

        $holds = $xml->getElementsByTagName('hold');
        $static->holds = HoldCollection::fromXml($holds);

        $expenses = $xml->getElementsByTagName('fine');
        $static->expenses = ExpenseCollection::fromXml($expenses);

        $totalFine = $xml->getElementsByTagName('totalFine');
        $static->totalFine = FloatLiteral::fromXml($totalFine);

        $totalCost = $xml->getElementsByTagName('totalCost');
        $static->totalCost = FloatLiteral::fromXml($totalCost);

        $message = $xml->getElementsByTagName('message');
        $static->message = StringLiteral::fromXml($message);

        $loanHistoryConfig = $xml->getElementsByTagName('loanHistoryConfigurable');
        $static->loanHistoryConfigurable = BoolLiteral::fromXml($loanHistoryConfig);

        return $static;
    }
853336
public function inject(Xml $element)
	{
		$element->setAncestor($this->getAncestor());
		$element->setRoot($this->getRoot());
		$element->parent = $this;
		return $this->appendChild($element);
	}
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();
    }
1255466
public function process(\DOMDocument $xml)
    {
        $ignoreQry = '//tag[@name=\'' . $this->tag . '\']';

        $xpath = new \DOMXPath($xml);
        $nodes = $xpath->query($ignoreQry);

        /** @var \DOMElement $node */
        foreach ($nodes as $node) {
            $remove = $node->parentNode->parentNode;

            // sometimes the parent node of the entity-to-be-removed is already
            // gone; for instance when a File docblock contains an @internal and
            // the underlying class also contains an @internal.
            // Because the File Docblock is found sooner, it is removed first.
            // Without the following check the application would fatal since
            // it cannot find, and then remove, this node from the parent.
            if (!isset($remove->parentNode)) {
                continue;
            }

            $remove->parentNode->removeChild($remove);
        }

        return $xml;
    }
338106
public function FromXML($xml)
	{
		$sxo = new SimpleXMLElement($xml);
		
		if($sxo->encoding == "base64")
		{
			$this->Data = base64_decode($sxo->data);
		}
		else
		{
			$this->Data = $sxo->data;
		}
		
		$this->Name = $attachment->name;
		$this->Type = $attachment->type;
		$this->Size = $attachment->size;
		$this->Extension = $attachment->extension;
	}
1151396
protected function loadXml( $xml )
	{
		$xsv	= new XML_DOM_SyntaxValidator;
		if( !$xsv->validate( $xml ) )
			throw new Exception( "XML Document is not valid:".$xsv->getErrors() );
		$this->document	= $xsv->getDocument();
		$this->clearOptions();
		foreach( $this->attributes as $attribute )
			if( isset( $this->document->$attribute ) )
				$this->setOption( $attribute, $this->document->$attribute );
	}
1158247
public function build (SimpleXMLElement $xml)
    {
        // Start parsing the input.
        $function = preg_replace_callback('/(_)([a-z])/', function ($matches) {
            return strtoupper($matches[1]);
        }, strtolower($xml->MsgType));
        $callable = [$this, "parse{$function}Input"];

        if (is_callable($callable)) {
            $input = call_user_func($callable, $xml);
        } else {
            throw new UnknownInputTypeException($xml->MsgType);
        }
        
        return $input;
    }
856223
private function createStorageElement($xml)
    {
        $storage = $xml->createElement('storage');
        $type    = $xml->createElement($this->storage['type']);
        $this->addAttributes($type, $this->storage, ['type']);
        $storage->appendChild($type);

        return $storage;
    }
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;
    }
769060
protected static function xml2Data($xml)
    {
        $result = null;
        is_object($xml) && $xml = (array)$xml;
        if (is_array($xml)) {
            foreach ($xml as $key => $value) {
                $res = static::xml2Data($value);
                if (('@attributes' === $key) && ($key)) {
                    $result = $res;
                } else {
                    $result[$key] = $res;
                }
            }
        } else {
            $result = $xml;
        }
        return $result;
    }
606404
public static function fromXML($xml)
    {
        $dom = new DOMDocument();
        $dom->loadXML($xml);
        $xpath = new DOMXPath($dom);
        $xpath->registerNamespace('a', self::getNamespace());
        $response = $xpath->query('//a:CaptureNotification');
        if ($response->length == 1) {
            return 
                new OffAmazonPaymentsNotifications_Model_CaptureNotification(
                    $response->item(0)
                );
        } else {
            throw new Exception(
                "Unable to construct " .
                "OffAmazonPaymentsNotifications_Model_CaptureNotification" .
                "from provided XML. Make sure that CaptureNotification" .
                "is a root element"
            );
        }
    }
1070820
public function doProcess( $xml ) {

		$domDocument = new DOMDocument();
		$domDocument->loadXml( $xml );

		$this->findElementsForPubMed( $domDocument );
		$this->findElementsForPubMedCentral( $domDocument );
	}
574278
private function createRelationsElement($xml)
    {
        $relations = $xml->createElement('relations');

        foreach ($this->relations as $type => $rr) {
            foreach ($rr as $relation) {
                $relations->appendChild($this->createRelationElement($xml, $type, $relation));
            }
        }

        return $relations;
    }
989768
public function createEntityDescriptor($xml)
    {
        $deserializationContext = new DeserializationContext();
        $deserializationContext->getDocument()->loadXML($xml);

        $ed = new EntityDescriptor();
        $ed->deserialize($deserializationContext->getDocument(), $deserializationContext);

        return $ed;
    }
590472
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();
	}
1276236
private function xmlToElements($xml)
    {
        //====================================================================//
        // Convert XML to Object Recursively
        try {
            $result = simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOERROR);
        } catch (Exception $ex) {
            $this->fault = $ex->getMessage();

            return false;
        }

        return $result;
    }
735193
protected function __parseXmlToUpdateObject($xml)
  {
    $dom = new DOMDocument();

    // Attempt to prevent XXE that could be exploited through loadXML()
    libxml_disable_entity_loader(true);

    if (empty($xml) || !$dom->loadXML($xml, LIBXML_NOBLANKS)) return null;

    $rootNode = $dom->documentElement;

    if ($rootNode->nodeName == $this->getNodeName()) {
      // update the current object
      Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $this, $this->_client);
    } else if ($rootNode->nodeName == 'errors') {
      // add element to existing object
      Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $this->_errors, $this->_client);
    }
    $this->updateErrorAttributes();
  }