本文整理汇总了PHP中xmlize函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlize函数的具体用法?PHP xmlize怎么用?PHP xmlize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readquestions
/**
* Parse the array of lines into an array of questions
* this *could* burn memory - but it won't happen that much
* so fingers crossed!
* @param array of lines from the input file.
* @param stdClass $context
* @return array (of objects) question objects.
*/
protected function readquestions($lines) {
$text = implode($lines, ' ');
unset($lines);
// This converts xml to big nasty data structure,
// the 0 means keep white space as it is.
try {
$xml = xmlize($text, 0, 'UTF-8', true);
} catch (xml_format_exception $e) {
$this->error($e->getMessage(), '');
return false;
}
$questions = array();
$this->process_tf($xml, $questions);
$this->process_mc($xml, $questions);
$this->process_ma($xml, $questions);
$this->process_fib($xml, $questions);
$this->process_matching($xml, $questions);
$this->process_essay($xml, $questions);
return $questions;
}
示例2: import
/**
* import
*
* @param string $xml
* @param object $block_instance
* @param object $course
* @return boolean true if import was successful, false otherwise
*/
public function import($xml, $block_instance, $course)
{
global $DB;
if (!($xml = xmlize($xml, 0))) {
return false;
}
// set main XML tag name for this block's config settings
$BLOCK = strtoupper($block_instance->blockname);
$BLOCK = strtr($BLOCK, array('_' => '')) . 'BLOCK';
if (!isset($xml[$BLOCK]['#']['CONFIGFIELDS'][0]['#']['CONFIGFIELD'])) {
return false;
}
$configfield =& $xml[$BLOCK]['#']['CONFIGFIELDS'][0]['#']['CONFIGFIELD'];
$config = unserialize(base64_decode($block_instance->configdata));
if (empty($config)) {
$config = new stdClass();
}
$i = 0;
while (isset($configfield[$i]['#'])) {
$name = $configfield[$i]['#']['NAME'][0]['#'];
$value = $configfield[$i]['#']['VALUE'][0]['#'];
$config->{$name} = $value;
$i++;
}
if ($i == 0) {
return false;
}
$block_instance->configdata = base64_encode(serialize($config));
$DB->set_field('block_instances', 'configdata', $block_instance->configdata, array('id' => $block_instance->id));
return true;
}
示例3: readquestions
/**
* Parse the xml document into an array of questions
* this *could* burn memory - but it won't happen that much
* so fingers crossed!
* @param array of lines from the input file.
* @param stdClass $context
* @return array (of objects) questions objects.
*/
protected function readquestions($text) {
// This converts xml to big nasty data structure,
// the 0 means keep white space as it is.
try {
$xml = xmlize($text, 0, 'UTF-8', true);
} catch (xml_format_exception $e) {
$this->error($e->getMessage(), '');
return false;
}
$questions = array();
// Treat the assessment title as a category title.
$this->process_category($xml, $questions);
// First step : we are only interested in the <item> tags.
$rawquestions = $this->getpath($xml,
array('questestinterop', '#', 'assessment', 0, '#', 'section', 0, '#', 'item'),
array(), false);
// Each <item> tag contains data related to a single question.
foreach ($rawquestions as $quest) {
// Second step : parse each question data into the intermediate
// rawquestion structure array.
// Warning : rawquestions are not Moodle questions.
$question = $this->create_raw_question($quest);
// Third step : convert a rawquestion into a Moodle question.
switch($question->qtype) {
case "Matching":
$this->process_matching($question, $questions);
break;
case "Multiple Choice":
$this->process_mc($question, $questions);
break;
case "Essay":
$this->process_essay($question, $questions);
break;
case "Multiple Answer":
$this->process_ma($question, $questions);
break;
case "True/False":
$this->process_tf($question, $questions);
break;
case 'Fill in the Blank':
$this->process_fblank($question, $questions);
break;
case 'Short Response':
$this->process_essay($question, $questions);
break;
default:
$this->error(get_string('unknownorunhandledtype', 'question', $question->qtype));
break;
}
}
return $questions;
}
示例4: rss
function rss($a)
{
// $a deve ser o caminho para o rss
// Primeiro armazenamos o xml
$data = file_get_contents($a);
$info = xmlize($data, 1, 'ISO-8859-1');
$this->title = $info["rss"]["#"]["channel"][0]["#"]["title"][0]["#"];
// Titulo do RSS
$this->link = $info["rss"]["#"]["channel"][0]["#"]["link"][0]["#"];
// Link para a pagina
$this->itens = $info["rss"]["#"]["channel"][0]["#"]["item"];
// Conteudo do RSS
}
示例5: readquestions
function readquestions($lines)
{
/// Parses an array of lines into an array of questions,
/// where each item is a question object as defined by
/// readquestion().
$text = implode($lines, " ");
$xml = xmlize($text, 0);
$questions = array();
$this->process_tf($xml, $questions);
$this->process_mc($xml, $questions);
$this->process_ma($xml, $questions);
$this->process_fib($xml, $questions);
$this->process_matching($xml, $questions);
return $questions;
}
示例6: validation
function validation($data, $files) {
$errors = array();
if($file = $this->get_draft_files('importfile')){
$file = reset($file);
$content = $file->get_content();
$xml = xmlize($content);
if(empty($content)){
$errors['importfile'] = get_string('error_emptyfile', 'report_rolesmigration');
}else if(!$xml || !roles_migration_get_incoming_roles($xml)){
$errors['importfile'] = get_string('error_badxml', 'report_rolesmigration');
}
}
return $errors;
}
示例7: loadXMLStructure
/**
* Load and the XMLDB structure from file
*/
function loadXMLStructure()
{
if ($this->fileExists()) {
/// File exists, so let's process it
/// Load everything to a big array
$contents = file_get_contents($this->path);
if (function_exists('local_xmldb_contents_sub')) {
local_xmldb_contents_sub($contents);
}
$xmlarr = xmlize($contents);
/// Convert array to xmldb structure
$this->xmldb_structure = $this->arr2XMLDBStructure($xmlarr);
/// Analize results
if ($this->xmldb_structure->isLoaded()) {
$this->loaded = true;
return true;
} else {
return false;
}
}
return true;
}
示例8: get_preset_settings
/**
* Gets the preset settings
* @global moodle_database $DB
* @return stdClass
*/
public function get_preset_settings() {
global $DB;
$fs = $fileobj = null;
if (!is_directory_a_preset($this->directory)) {
//maybe the user requested a preset stored in the Moodle file storage
$fs = get_file_storage();
$files = $fs->get_area_files(DATA_PRESET_CONTEXT, DATA_PRESET_COMPONENT, DATA_PRESET_FILEAREA);
//preset name to find will be the final element of the directory
$presettofind = end(explode('/',$this->directory));
//now go through the available files available and see if we can find it
foreach ($files as $file) {
if (($file->is_directory() && $file->get_filepath()=='/') || !$file->is_directory()) {
continue;
}
$presetname = trim($file->get_filepath(), '/');
if ($presetname==$presettofind) {
$this->directory = $presetname;
$fileobj = $file;
}
}
if (empty($fileobj)) {
print_error('invalidpreset', 'data', '', $this->directory);
}
}
$allowed_settings = array(
'intro',
'comments',
'requiredentries',
'requiredentriestoview',
'maxentries',
'rssarticles',
'approval',
'defaultsortdir',
'defaultsort');
$result = new stdClass;
$result->settings = new stdClass;
$result->importfields = array();
$result->currentfields = $DB->get_records('data_fields', array('dataid'=>$this->module->id));
if (!$result->currentfields) {
$result->currentfields = array();
}
/* Grab XML */
$presetxml = $this->data_preset_get_file_contents($fs, $fileobj, $this->directory,'preset.xml');
$parsedxml = xmlize($presetxml, 0);
/* First, do settings. Put in user friendly array. */
$settingsarray = $parsedxml['preset']['#']['settings'][0]['#'];
$result->settings = new StdClass();
foreach ($settingsarray as $setting => $value) {
if (!is_array($value) || !in_array($setting, $allowed_settings)) {
// unsupported setting
continue;
}
$result->settings->$setting = $value[0]['#'];
}
/* Now work out fields to user friendly array */
$fieldsarray = $parsedxml['preset']['#']['field'];
foreach ($fieldsarray as $field) {
if (!is_array($field)) {
continue;
}
$f = new StdClass();
foreach ($field['#'] as $param => $value) {
if (!is_array($value)) {
continue;
}
$f->$param = $value[0]['#'];
}
$f->dataid = $this->module->id;
$f->type = clean_param($f->type, PARAM_ALPHA);
$result->importfields[] = $f;
}
/* Now add the HTML templates to the settings array so we can update d */
$result->settings->singletemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"singletemplate.html");
$result->settings->listtemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"listtemplate.html");
$result->settings->listtemplateheader = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"listtemplateheader.html");
$result->settings->listtemplatefooter = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"listtemplatefooter.html");
$result->settings->addtemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"addtemplate.html");
$result->settings->rsstemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"rsstemplate.html");
$result->settings->rsstitletemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"rsstitletemplate.html");
$result->settings->csstemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"csstemplate.css");
$result->settings->jstemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"jstemplate.js");
//optional
if (file_exists($this->directory."/asearchtemplate.html")) {
//.........这里部分代码省略.........
示例9: readquestions
/**
* Parse the array of lines into an array of questions
* this *could* burn memory - but it won't happen that much
* so fingers crossed!
* @param array of lines from the input file.
* @param stdClass $context
* @return array (of objects) question objects.
*/
protected function readquestions($lines)
{
// We just need it as one big string
$lines = implode('', $lines);
// This converts xml to big nasty data structure
// the 0 means keep white space as it is (important for markdown format)
try {
$xml = xmlize($lines, 0, 'UTF-8', true);
} catch (xml_format_exception $e) {
$this->error($e->getMessage(), '');
return false;
}
unset($lines);
// No need to keep this in memory.
// Set up array to hold all our questions
$questions = array();
// Iterate through questions
foreach ($xml['quiz']['#']['question'] as $question) {
$questiontype = $question['@']['type'];
if ($questiontype == 'multichoice') {
$qo = $this->import_multichoice($question);
} else {
if ($questiontype == 'truefalse') {
$qo = $this->import_truefalse($question);
} else {
if ($questiontype == 'shortanswer') {
$qo = $this->import_shortanswer($question);
} else {
if ($questiontype == 'numerical') {
$qo = $this->import_numerical($question);
} else {
if ($questiontype == 'description') {
$qo = $this->import_description($question);
} else {
if ($questiontype == 'matching' || $questiontype == 'match') {
$qo = $this->import_match($question);
} else {
if ($questiontype == 'cloze' || $questiontype == 'multianswer') {
$qo = $this->import_multianswer($question);
} else {
if ($questiontype == 'essay') {
$qo = $this->import_essay($question);
} else {
if ($questiontype == 'calculated') {
$qo = $this->import_calculated($question);
} else {
if ($questiontype == 'calculatedsimple') {
$qo = $this->import_calculated($question);
$qo->qtype = 'calculatedsimple';
} else {
if ($questiontype == 'calculatedmulti') {
$qo = $this->import_calculated($question);
$qo->qtype = 'calculatedmulti';
} else {
if ($questiontype == 'category') {
$qo = $this->import_category($question);
} else {
// Not a type we handle ourselves. See if the question type wants
// to handle it.
if (!($qo = $this->try_importing_using_qtypes($question, null, null, $questiontype))) {
$this->error(get_string('xmltypeunsupported', 'qformat_xml', $questiontype));
$qo = null;
}
}
}
}
}
}
}
}
}
}
}
}
}
// Stick the result in the $questions array
if ($qo) {
$questions[] = $qo;
}
}
return $questions;
}
示例10: endElementLogs
function endElementLogs($parser, $tagName)
{
//Check if we are into LOGS zone
if ($this->tree[3] == "LOGS") {
//if (trim($this->content)) //Debug
// echo "C".str_repeat(" ",($this->level+2)*2).$this->getContents()."<br />\n"; //Debug
//echo $this->level.str_repeat(" ",$this->level*2)."</".$tagName."><br />\n"; //Debug
//Acumulate data to info (content + close tag)
//Reconvert: strip htmlchars again and trim to generate xml data
if (!isset($this->temp)) {
$this->temp = "";
}
$this->temp .= htmlspecialchars(trim($this->content)) . "</" . $tagName . ">";
//If we've finished a log, xmlize it an save to db
if ($this->level == 4 and $tagName == "LOG") {
//Prepend XML standard header to info gathered
$xml_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $this->temp;
//Call to xmlize for this portion of xml data (one LOG)
//echo "-XMLIZE: ".strftime ("%X",time()),"-"; //Debug
$data = xmlize($xml_data, 0);
//echo strftime ("%X",time())."<p>"; //Debug
//traverse_xmlize($data); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, save data to db. We'll use it later
//Get id and modtype from data
$log_id = $data["LOG"]["#"]["ID"]["0"]["#"];
$log_module = $data["LOG"]["#"]["MODULE"]["0"]["#"];
//We only save log entries from backup file if they are:
// - Course logs
// - User logs
// - Module logs about one restored module
if ($log_module == "course" or $log_module == "user" or $this->preferences->mods[$log_module]->restore) {
//Increment counter
$this->counter++;
//Save to db
$status = backup_putid($this->preferences->backup_unique_code, "log", $log_id, null, $data);
//echo "<p>id: ".$mod_id."-".$mod_type." len.: ".strlen($sla_mod_temp)." to_db: ".$status."<p>"; //Debug
//Create returning info
$this->info = $this->counter;
}
//Reset temp
unset($this->temp);
}
}
//Stop parsing if todo = LOGS and tagName = LOGS (en of the tag, of course)
//Speed up a lot (avoid parse all)
if ($tagName == "LOGS" and $this->level == 3) {
$this->finished = true;
$this->counter = 0;
}
//Clear things
$this->tree[$this->level] = "";
$this->level--;
$this->content = "";
}
示例11: ping_init
function ping_init(&$a)
{
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\t\t<result>";
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
if (local_user()) {
$tags = array();
$comments = array();
$likes = array();
$dislikes = array();
$friends = array();
$posts = array();
$cit = array();
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, \n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, `item`.`body`, \n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` \n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 \n\t\t\t\tORDER BY `item`.`created` DESC", intval(local_user()));
$network = count($r);
foreach ($r as $it) {
switch ($it['verb']) {
case ACTIVITY_TAG:
$obj = parse_xml_string($xmlhead . $it['object']);
$it['tname'] = $obj->content;
$tags[] = $it;
break;
case ACTIVITY_LIKE:
$likes[] = $it;
break;
case ACTIVITY_DISLIKE:
$dislikes[] = $it;
break;
case ACTIVITY_FRIEND:
$obj = parse_xml_string($xmlhead . $it['object']);
$it['fname'] = $obj->title;
$friends[] = $it;
break;
default:
$reg = "|@\\[url=" . $a->get_baseurl() . "/profile/" . $a->user['nickname'] . "|";
if ($it['parent'] != $it['id']) {
$comments[] = $it;
} else {
if (preg_match($reg, $it['body'])) {
$cit[] = $it;
} else {
$posts[] = $it;
}
}
}
}
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, \n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, \n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` \n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1", intval(local_user()));
$home = count($r);
foreach ($r as $it) {
switch ($it['verb']) {
case ACTIVITY_TAG:
$obj = parse_xml_string($xmlhead . $it['object']);
$it['tname'] = $obj->content;
$tags[] = $it;
break;
case ACTIVITY_LIKE:
$likes[] = $it;
break;
case ACTIVITY_DISLIKE:
$dislikes[] = $it;
break;
case ACTIVITY_FRIEND:
$obj = parse_xml_string($xmlhead . $it['object']);
$it['fname'] = $obj->title;
$friends[] = $it;
break;
default:
if ($it['parent'] != $it['id']) {
$comments[] = $it;
}
if (preg_match("/@\\[[^]]*\\]" . $a->user['username'] . "/", $it['body'])) {
$cit[] = $it;
}
}
}
$intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`, \n\t\t\t`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo` \n\t\t\tFROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`\n\t\t\tWHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0", intval(local_user()));
$intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`, \n\t\t\t`contact`.`name`, `contact`.`url`, `contact`.`photo` \n\t\t\tFROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`\n\t\t\tWHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0", intval(local_user()));
$intro = $intros1[0]['total'] + $intros2[0]['total'];
if ($intros1[0]['total'] == 0) {
$intros1 = array();
}
if ($intros2[0]['total'] == 0) {
$intros2 = array();
}
$intros = $intros1 + $intros2;
$myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
$mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`\n\t\t\tWHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", intval(local_user()), dbesc($myurl));
$mail = $mails[0]['total'];
if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
$regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
$register = $regs[0]['total'];
} else {
$register = "0";
}
function xmlize($href, $name, $url, $photo, $date, $message)
{
$notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
return sprintf($notsxml, xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message));
}
echo "<intro>{$intro}</intro>\n\t\t\t\t<mail>{$mail}</mail>\n\t\t\t\t<net>{$network}</net>\n\t\t\t\t<home>{$home}</home>";
//.........这里部分代码省略.........
示例12: file_get_contents
<?php
//====================================================
// FileName: .php
// Summary: 描述
// Author: millken(迷路林肯)
// LastModifed:2007-08-10
// copyright (c)2007 millken@gmail.com
//====================================================
include 'common.inc.php';
include ROOT_PATH . 'include/xmlize.inc.php';
$xmldata = file_get_contents(ROOT_PATH . 'cache/top500.xml');
$xml = xmlize($xmldata);
foreach ($xml['result']['#']['data'] as $x) {
$temp = explode('$$', $x['#']['name']['0']['#']);
$list_array[] = array('id' => $x['#']['id']['0']['#'], 'songname' => $temp[0], 'singer' => $temp[1]);
}
//print_r($list_array);
//$lines = file('temp.txt');
//foreach($lines as $l){
// $newContent .= " <Keyword>".trim($l)."</Keyword>\n";
//}
//file_put_contents('new.txt',$newContent);
function &a($a = '')
{
echo func_num_args();
}
a();
print_r(ini_get_all());
示例13: load_environment_xml
/**
* This function will load the environment.xml file and xmlize it
*
* @global object
* @staticvar mixed $data
* @uses ENV_SELECT_NEWER
* @uses ENV_SELECT_DATAROOT
* @uses ENV_SELECT_RELEASE
* @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. Default ENV_SELECT_NEWER (BC)
* @return mixed the xmlized structure or false on error
*/
function load_environment_xml($env_select = ENV_SELECT_NEWER)
{
global $CFG;
static $data;
//Only load and xmlize once by request
if (!empty($data)) {
return $data;
}
/// First of all, take a look inside $CFG->dataroot/environment/environment.xml
$file = $CFG->dataroot . '/environment/environment.xml';
$internalfile = $CFG->dirroot . '/' . $CFG->admin . '/environment.xml';
switch ($env_select) {
case ENV_SELECT_NEWER:
if (!is_file($file) || !is_readable($file) || filemtime($file) < filemtime($internalfile) || !($contents = file_get_contents($file))) {
/// Fallback to fixed $CFG->admin/environment.xml
if (!is_file($internalfile) || !is_readable($internalfile) || !($contents = file_get_contents($internalfile))) {
return false;
}
}
break;
case ENV_SELECT_DATAROOT:
if (!is_file($file) || !is_readable($file) || !($contents = file_get_contents($file))) {
return false;
}
break;
case ENV_SELECT_RELEASE:
if (!is_file($internalfile) || !is_readable($internalfile) || !($contents = file_get_contents($internalfile))) {
return false;
}
break;
}
/// XML the whole file
$data = xmlize($contents);
return $data;
}
示例14: feedback_load_xml_data
function feedback_load_xml_data($filename)
{
global $CFG;
require_once $CFG->dirroot . '/lib/xmlize.php';
$datei = file_get_contents($filename);
if (!($datei = feedback_check_xml_utf8($datei))) {
return false;
}
$data = xmlize($datei, 1, 'UTF-8');
if (intval($data['FEEDBACK']['@']['VERSION']) != 200701) {
return false;
}
$data = $data['FEEDBACK']['#']['ITEMS'][0]['#']['ITEM'];
return $data;
}
示例15: test_import_files_as_draft
public function test_import_files_as_draft() {
$this->resetAfterTest();
$this->setAdminUser();
$xml = <<<END
<questiontext format="html">
<text><![CDATA[<p><a href="@@PLUGINFILE@@/moodle.txt">This text file</a> contains the word 'Moodle'.</p>]]></text>
<file name="moodle.txt" encoding="base64">TW9vZGxl</file>
</questiontext>
END;
$textxml = xmlize($xml);
$qo = new stdClass();
$importer = new qformat_xml();
$draftitemid = $importer->import_files_as_draft($textxml['questiontext']['#']['file']);
$files = file_get_drafarea_files($draftitemid);
$this->assertEquals(1, count($files->list));
$file = $files->list[0];
$this->assertEquals('moodle.txt', $file->filename);
$this->assertEquals('/', $file->filepath);
$this->assertEquals(6, $file->size);
}