public static function formXml($xml, $file)
    {
        $xml = simplexml_load_string($xml);
        /** @var  $dataArray \SimpleXMLElement[] */
        $dataArray = $xml->attributes();

        $dataFileInfo = new DataFileInfo();
        if (isset($dataArray['Id'])) {
            $dataFileInfo->setId($dataArray['Id']->__toString());
        }
        if (isset($dataArray['Filename'])) {
            $dataFileInfo->setFilename($dataArray['Filename']->__toString());
        }
        if (isset($dataArray['ContentType'])) {
            $dataFileInfo->setContentType($dataArray['ContentType']->__toString());
        }
        if (isset($dataArray['MimeType'])) {
            $dataFileInfo->setMimeType($dataArray['MimeType']->__toString());
        }
        if (isset($dataArray['Size'])) {
            $dataFileInfo->setSize($dataArray['Size']->__toString());
        }
        if (isset($dataArray['DigestType'])) {
            $dataFileInfo->setDigestType($dataArray['DigestType']->__toString());
        }
        if (isset($dataArray['DigestValue'])) {
            $dataFileInfo->setDigestValue($dataArray['DigestValue']->__toString());
        }
        if (isset($dataArray['DfData'])) {
            $dataFileInfo->setDfData($dataArray['DfData']->__toString());
        } elseif (file_exists($file)) {
            $dataFileInfo->setDfData(base64_encode(file_get_contents($file)));
        }

        // TODO: validate data

        return $dataFileInfo;
    }
public static function formXml($xml, $file)
    {
        $xml = simplexml_load_string($xml);
        /** @var  $dataArray \SimpleXMLElement[] */
        $dataArray = $xml->attributes();

        $dataFileInfo = new DataFileInfo();
        if (isset($dataArray['Id'])) {
            $dataFileInfo->setId($dataArray['Id']->__toString());
        }
        if (isset($dataArray['Filename'])) {
            $dataFileInfo->setFilename($dataArray['Filename']->__toString());
        }
        if (isset($dataArray['ContentType'])) {
            $dataFileInfo->setContentType($dataArray['ContentType']->__toString());
        }
        if (isset($dataArray['MimeType'])) {
            $dataFileInfo->setMimeType($dataArray['MimeType']->__toString());
        }
        if (isset($dataArray['Size'])) {
            $dataFileInfo->setSize($dataArray['Size']->__toString());
        }
        if (isset($dataArray['DigestType'])) {
            $dataFileInfo->setDigestType($dataArray['DigestType']->__toString());
        }
        if (isset($dataArray['DigestValue'])) {
            $dataFileInfo->setDigestValue($dataArray['DigestValue']->__toString());
        }
        if (isset($dataArray['DfData'])) {
            $dataFileInfo->setDfData($dataArray['DfData']->__toString());
        } elseif (file_exists($file)) {
            $dataFileInfo->setDfData(base64_encode(file_get_contents($file)));
        }

        // TODO: validate data

        return $dataFileInfo;
    }
public static function formXml ( $ xml , $ file ) { $ xml = simplexml_load_string ( $ xml ) ; /** @var  $dataArray \SimpleXMLElement[] */ $ dataArray = $ xml -> attributes ( ) ; $ dataFileInfo = new DataFileInfo ( ) ; if ( isset ( $ dataArray [ 'Id' ] ) ) { $ dataFileInfo -> setId ( $ dataArray [ 'Id' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'Filename' ] ) ) { $ dataFileInfo -> setFilename ( $ dataArray [ 'Filename' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'ContentType' ] ) ) { $ dataFileInfo -> setContentType ( $ dataArray [ 'ContentType' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'MimeType' ] ) ) { $ dataFileInfo -> setMimeType ( $ dataArray [ 'MimeType' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'Size' ] ) ) { $ dataFileInfo -> setSize ( $ dataArray [ 'Size' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'DigestType' ] ) ) { $ dataFileInfo -> setDigestType ( $ dataArray [ 'DigestType' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'DigestValue' ] ) ) { $ dataFileInfo -> setDigestValue ( $ dataArray [ 'DigestValue' ] -> __toString ( ) ) ; } if ( isset ( $ dataArray [ 'DfData' ] ) ) { $ dataFileInfo -> setDfData ( $ dataArray [ 'DfData' ] -> __toString ( ) ) ; } elseif ( file_exists ( $ file ) ) { $ dataFileInfo -> setDfData ( base64_encode ( file_get_contents ( $ file ) ) ) ; } // TODO: validate data return $ dataFileInfo ; }
Creates new DataFileInfo from xml element

@param $xml
@param $file
@return DataFileInfo
Creates new DataFileInfo from xml element