Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在laravel中使用xml文件发布_Laravel - Fatal编程技术网

在laravel中使用xml文件发布

在laravel中使用xml文件发布,laravel,Laravel,我使用方法post在xml文件中创建新数据,但函数c_元素不能在函数存储中使用 $DeTai = c_element('DeTai', $root); 这是我当前的代码: public function c_element($e_name, $parent) { global $xml; $node = $xml->createElement($e_name); $parent->appendChild($node); return $node; }

我使用方法post在xml文件中创建新数据,但函数c_元素不能在函数存储中使用

$DeTai = c_element('DeTai', $root);
这是我当前的代码:

public function c_element($e_name, $parent)
{
    global $xml;
    $node = $xml->createElement($e_name);
    $parent->appendChild($node);
    return $node;
}
public function c_value($value, $parent)
{
    global $xml;
    $value = $xml->createTextNode($value);
    $parent->appendChild($value);
    return $value;
}
public function store(Request $request)
{
    $xml = new DOMDocument("1.0","UTF-8");
    $xml->load('../xml/QuanLyDoAnTotNghiep.xml');

    if ($request->isMethod('post')) 
    {
        $madt= $request->madt;
        $noidungdetai = $request->noidungdetai;
        $root=$xml->getElementsByTagName("QuanLyDoAnTotNghiep")->item(0);
            $DeTai = c_element("DeTai", $root); //error in here

            $s_madt = c_element('MaDT', $DeTai);
            c_value("$madt", $s_madt);
            $s_noidungdetai = c_element('NoiDungDeTai', $DeTai);
            c_value("$noidungdetai", $s_noidungdetai);

            $xml->formatOutput=true;
            $xml->save('../xml/QuanLyDoAnTotNghiep.xml');
            echo "Thêm mới thành công!!!";
    }   
}

使用
this
关键字调用同一
类的不同
方法中的一个
方法

$DeTai = $this->c_element('DeTai', $root);
欲了解更多信息,请访问

谢谢