当前位置: 首页>>代码示例>>PHP>>正文


PHP DomDocument::save方法代码示例

本文整理汇总了PHP中DomDocument::save方法的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument::save方法的具体用法?PHP DomDocument::save怎么用?PHP DomDocument::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DomDocument的用法示例。


在下文中一共展示了DomDocument::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: file_write

function file_write()
{
    extract($GLOBALS);
    $dom = new DomDocument('1.0', 'UTF-8');
    $prefs = $dom->appendChild($dom->createElement('prefs'));
    for ($i = 0; $i < 10; $i++) {
        $pref = $prefs->appendChild($dom->createElement('pref'));
        $pref->setAttribute('code', $power_company[$i] . '_Denryoku');
        $pref->appendChild($dom->createElement('den_per', $Power[$power_company[$i]]["den_per"]));
        $pref->appendChild($dom->createElement('den_old', $Power[$power_company[$i]]["OLD_DATA"]));
        $pref->appendChild($dom->createElement('den_now', $Power[$power_company[$i]]["usage"]));
        $pref->appendChild($dom->createElement('den_updown', $Power[$power_company[$i]]["up_down"]));
        $pref->appendChild($dom->createElement('den_max', $Power[$power_company[$i]]["capacity"]));
        $pref->appendChild($dom->createElement('den_yosou', $Power[$power_company[$i]]["yosou"]));
        $pref->appendChild($dom->createElement('den_date', $Power[$power_company[$i]]["DATE"]));
        $pref->appendChild($dom->createElement('den_time', $Power[$power_company[$i]]["time"]));
        $pref->appendChild($dom->createElement('den_alive', $Power[$power_company[$i]]["alive"]));
    }
    $weekjp = array('日', '月', '火', '水', '木', '金', '土');
    $weekno = date('w');
    $week_X = "〔" . $weekjp[$weekno] . "〕";
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'DATE');
    $pref->appendChild($dom->createElement('time', date("Y年m月d日") . $week_X . date(" H時i分")));
    $pref->appendChild($dom->createElement('time_ampm', date("Y年m月d日") . $week_X . date(" A h:i")));
    $pref->appendChild($dom->createElement('time_x', date("Ymd")));
    $dom->formatOutput = true;
    $save_file = "/etc/zabbix/externalscripts/" . $OUT_FILE;
    $dom->save($save_file);
}
开发者ID:mintwavio,项目名称:TanpopoWeather,代码行数:30,代码来源:PowerOutput.php

示例2: file_write

function file_write()
{
    extract($GLOBALS);
    $dom = new DomDocument('1.0', 'UTF-8');
    $prefs = $dom->appendChild($dom->createElement('prefs'));
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'SunMoon');
    $pref->appendChild($dom->createElement('sunrise', sprintf("%05s", $ohakon["sunrise"])));
    $pref->appendChild($dom->createElement('sunset', sprintf("%05s", $ohakon["sunset"])));
    $pref->appendChild($dom->createElement('sunrise_hm', sprintf("%05s", $ohakon["sunrise_hm"])));
    $pref->appendChild($dom->createElement('sunset_hm', sprintf("%05s", $ohakon["sunset_hm"])));
    $pref->appendChild($dom->createElement('moonrise', sprintf("%05s", $ohakon["moonrise"])));
    $pref->appendChild($dom->createElement('moonset', sprintf("%05s", $ohakon["moonset"])));
    $pref->appendChild($dom->createElement('moonrise_hm', sprintf("%05s", $ohakon["moonrise_hm"])));
    $pref->appendChild($dom->createElement('moonset_hm', sprintf("%05s", $ohakon["moonset_hm"])));
    $pref->appendChild($dom->createElement('moon_age', $ohakon["moon_age"]));
    $pref->appendChild($dom->createElement('moon_phase', $ohakon["moon_phase"]));
    $pref->appendChild($dom->createElement('fullmoon_wait', $ohakon["fullmoon_wait"]));
    $pref->appendChild($dom->createElement('newmoon_wait', $ohakon["newmoon_wait"]));
    $pref->appendChild($dom->createElement('tide_name', $tide_name));
    $weekjp = array('日', '月', '火', '水', '木', '金', '土');
    $weekno = date('w');
    $week_X = "〔" . $weekjp[$weekno] . "〕";
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'DATE');
    $pref->appendChild($dom->createElement('time', date("Y年m月j日") . $week_X . date(" H時i分")));
    $pref->appendChild($dom->createElement('time_ampm', date("Y年m月j日") . $week_X . date(" A h:i")));
    $dom->formatOutput = true;
    $save_file = "/etc/zabbix/externalscripts/" . $OUT_FILE;
    $dom->save($save_file);
}
开发者ID:mintwavio,项目名称:TanpopoWeather,代码行数:31,代码来源:SunMoon.php

示例3: createXml

 /**
  * @param $nameRoot - имя корня xml
  * @param $nameBigElement - имя узла в который записываются данные из массива $data
  * @param $data - массив с данными выгружеными из таблицы
  */
 function createXml($nameRoot, $nameBigElement, $data)
 {
     // создает XML-строку и XML-документ при помощи DOM
     $dom = new DomDocument($this->version, $this->encode);
     // добавление корня
     $root = $dom->appendChild($dom->createElement($nameRoot));
     // отбираем названия полей таблицы
     foreach (array_keys($data[0]) as $k) {
         if (is_string($k)) {
             $key[] = $k;
         }
     }
     // формируем элементы с данными
     foreach ($data as $d) {
         //добавление элемента $nameBigElement в корень
         $bigElement = $root->appendChild($dom->createElement($nameBigElement));
         foreach ($key as $k) {
             $element = $bigElement->appendChild($dom->createElement($k));
             $element->appendChild($dom->createTextNode($d[$k]));
         }
     }
     // сохраняем результат в файл
     $dom->save('format/' . $this->nameFile);
     unset($dom);
 }
开发者ID:AlexB2015,项目名称:dz32,代码行数:30,代码来源:XmlGenerate.class.php

示例4: file_write

function file_write()
{
    extract($GLOBALS);
    $dom = new DomDocument('1.0', 'UTF-8');
    $prefs = $dom->appendChild($dom->createElement('prefs'));
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'FullMoon');
    $pref->appendChild($dom->createElement('Date', $FM[0] . "-" . $FM[1] . "-" . $FM[2]));
    $pref->appendChild($dom->createElement('Time', $FM[3] . ":" . $FM[4] . ":" . $FM[5]));
    $day = day_diff(date('Y-m-d'), $FM[0] . "-" . $FM[1] . "-" . $FM[2]);
    if ($day < 0) {
        $day = "--";
    }
    $pref->appendChild($dom->createElement('Wait', $day));
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'NewMoon');
    $pref->appendChild($dom->createElement('Date', $NM[0] . "-" . $NM[1] . "-" . $NM[2]));
    $pref->appendChild($dom->createElement('Time', $NM[3] . ":" . $NM[4] . ":" . $NM[5]));
    $day = day_diff(date('Y-m-d'), $NM[0] . "-" . $NM[1] . "-" . $NM[2]);
    if ($day < 0) {
        $day = "--";
    }
    $pref->appendChild($dom->createElement('Wait', $day));
    $weekjp = array('日', '月', '火', '水', '木', '金', '土');
    $weekno = date('w');
    $week_X = "〔" . $weekjp[$weekno] . "〕";
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'DATE');
    $pref->appendChild($dom->createElement('time', date("Y年m月j日") . $week_X . date(" H時i分")));
    $pref->appendChild($dom->createElement('time_ampm', date("Y年m月j日") . $week_X . date(" A h:i")));
    $dom->formatOutput = true;
    $save_file = "/etc/zabbix/externalscripts/F_N_Moon.xml";
    $dom->save($save_file);
}
开发者ID:mintwavio,项目名称:TanpopoWeather,代码行数:34,代码来源:FullNewMoon.php

示例5: file_write

function file_write()
{
    extract($GLOBALS);
    $dom = new DomDocument('1.0', 'UTF-8');
    $prefs = $dom->appendChild($dom->createElement('prefs'));
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'OpenWeatherMap');
    $pref->appendChild($dom->createElement('place', $owm["place"]));
    $pref->appendChild($dom->createElement('description', $owm["description"]));
    $pref->appendChild($dom->createElement('clouds_value', $owm["clouds_value"]));
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'Wunderground');
    $pref->appendChild($dom->createElement('city', $wg["city"]));
    $pref->appendChild($dom->createElement('weather', $wg["weather"]));
    $pref->appendChild($dom->createElement('kazamuki2', $wg["kazamuki2"]));
    $pref->appendChild($dom->createElement('kazamuki_degrees', $wg["kazamuki_degrees"]));
    $pref->appendChild($dom->createElement('temp_now2', $wg["temp_now2"]));
    $pref->appendChild($dom->createElement('temp_now_f', $wg["temp_now_f"]));
    $pref->appendChild($dom->createElement('feelslike', $wg["feelslike"]));
    $pref->appendChild($dom->createElement('humidity_now2', $wg["humidity_now2"]));
    $pref->appendChild($dom->createElement('windspeed_now2', $wg["windspeed_now2"]));
    $pref->appendChild($dom->createElement('pressure_now2', $wg["pressure_now2"]));
    $pref->appendChild($dom->createElement('discomfort', $wg["fukai"]));
    $weekjp = array('日', '月', '火', '水', '木', '金', '土');
    $weekno = date('w');
    $week_X = "〔" . $weekjp[$weekno] . "〕";
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'DATE');
    $pref->appendChild($dom->createElement('time', date("Y年m月j日") . $week_X . date(" H時i分")));
    $pref->appendChild($dom->createElement('time_ampm', date("Y年m月j日") . $week_X . date(" A h:i")));
    $dom->formatOutput = true;
    $save_file = "/etc/zabbix/externalscripts/" . $OUT_FILE;
    $dom->save($save_file);
}
开发者ID:mintwavio,项目名称:TanpopoWeather,代码行数:34,代码来源:WeatherOutput.php

示例6: create_xml_droits

function create_xml_droits($array_section)
{
    $dom_document = new DomDocument("1.0", "UTF-8");
    $dom_document->formatOutput = true;
    $root = $dom_document->createElement("droits");
    $root = $dom_document->appendChild($root);
    foreach ($array_section as $nom_section => $droits) {
        $section = $dom_document->createElement("section");
        $section->setAttribute("name", $nom_section);
        $section = $root->appendChild($section);
        foreach ($droits as $nom_droit => $type_droit) {
            $droit = $dom_document->createElement("droit");
            $droit = $section->appendChild($droit);
            $nom = $dom_document->createElement("name");
            $nom = $droit->appendChild($nom);
            $textNom = $dom_document->createTextNode($nom_droit);
            $textNom = $nom->appendChild($textNom);
            $type = $dom_document->createElement("type");
            $type = $droit->appendChild($type);
            $textType = $dom_document->createTextNode($type_droit);
            $textType = $type->appendChild($textType);
        }
    }
    $dom_document->save(PATH_ROOT . 'inc/droits.xml');
}
开发者ID:shiooooooookun,项目名称:Nouweo_PHP,代码行数:25,代码来源:create_xml_droits.php

示例7: handle

 /**
  * Handle provided directory
  *
  * Optionally an existing result file can be provided
  *
  * If a valid file could be generated the file name is supposed to be
  * returned, otherwise return null.
  *
  * @param Project $project
  * @param string  $existingResult
  *
  * @return string
  */
 public function handle(Project $project, $existingResult = null)
 {
     if (!isset($project->analyzers['pdepend'])) {
         return;
     }
     $pdependResultFile = $project->dataDir . '/' . $project->analyzers['pdepend'];
     $document = new \DomDocument();
     $document->load($pdependResultFile);
     $xPath = new \DomXPath($document);
     foreach ($xPath->query('//package') as $packageNode) {
         $packageCommits = 0;
         foreach ($xPath->query('./class', $packageNode) as $classNode) {
             $fileNode = $xPath->query('./file', $classNode)->item(0);
             $file = $fileNode->getAttribute('name');
             $classCommits = $this->countGitChangesPerFileRange($project, $file, $classNode->getAttribute('start'), $classNode->getAttribute('end'));
             $packageCommits += $classCommits;
             $classNode->setAttribute('commits', $classCommits);
             foreach ($xPath->query('./method', $classNode) as $methodNode) {
                 $methodCommits = $this->countGitChangesPerFileRange($project, $file, $methodNode->getAttribute('start'), $methodNode->getAttribute('end'));
                 $methodNode->setAttribute('commits', $methodCommits);
             }
         }
         $packageNode->setAttribute('commits', $packageCommits);
     }
     $document->save($pdependResultFile);
     return null;
 }
开发者ID:Qafoo,项目名称:QualityAnalyzer,代码行数:40,代码来源:GitDetailed.php

示例8: teste

 function teste()
 {
     $xml = new DomDocument("1.0", "UTF-8");
     /*
     $container = $xml->createElement('container', 'tkjasdkfjal');
     $container = $xml->appendChild($container);
     
     
     $sale = $xml->createElement('sale');
     $sale = $container->appendChild($sale);
     
     
     $item = $xml->createElement('item', 'Television');
     $item = $sale->appendChild($item);
     
     $price = $xml->createElement('price', '$100');
     $price = $sale->appendChild($price);
     */
     $cadastro = $xml->createElement('Cadastro');
     $cadastro = $xml->appendChild($cadastro);
     $pessoa = $xml->createElement('Pessoa');
     $pessoa = $cadastro->appendChild($pessoa);
     $nome = $xml->createElement('nome', 'Rodrigo');
     $pessoa->appendChild($nome);
     $situacao = $xml->createElement('situacao', 'fudido');
     $pessoa->appendChild($situacao);
     $xml->FormatOutput = true;
     $string_value = $xml->saveXML();
     $xml->save('xml/teste.xml');
     echo 'xml criado, chupa mundo';
     exit;
     //$xml = Xml::build('<example>text</example>', array('app/teste.xml'));
     //exit;
 }
开发者ID:rodrigofigueira,项目名称:leste_homolog,代码行数:34,代码来源:TestesxmlController.php

示例9: generate

 public static function generate()
 {
     // Там еще в сайтмепе есть приоритетность. Для главной ставим самую высокую, для всех категорий чуть ниже и последняя приоритетность для постов
     //Создает XML-строку и XML-документ при помощи DOM
     $dom = new DomDocument('1.0');
     //добавление корня - <books>
     $urlset = $dom->appendChild($dom->createElement('urlset'));
     $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     // Главная страница
     $url = $urlset->appendChild($dom->createElement('url'));
     $loc = $url->appendChild($dom->createElement('loc'));
     $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME']));
     $priority = $url->appendChild($dom->createElement('priority'));
     $priority->appendChild($dom->createTextNode('1.0'));
     // Категории фото
     $categoryPhoto = CategoryPhoto::find()->all();
     foreach ($categoryPhoto as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/photo/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Категории видео
     $categoryVideo = Category::find()->all();
     foreach ($categoryVideo as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/video/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Страницы фото
     $photoCatalog = PhotoCatalog::find()->where('publish = 1')->all();
     foreach ($photoCatalog as $photo) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/photo/" . $photo->category->url . "/" . $photo->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     // Страницы видео
     $videos = Video::find()->where('publish = 1')->all();
     foreach ($videos as $video) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/video/" . $video->category->url . "/" . $video->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     //генерация xml
     $dom->formatOutput = true;
     // установка атрибута formatOutput
     // domDocument в значение true
     // save XML as string or file
     //$test1 = $dom->saveXML(); // передача строки в test1
     $dom->save('../web/sitemap.xml');
     // сохранение файла
 }
开发者ID:Romario25,项目名称:porka,代码行数:59,代码来源:SitemapGenerate.php

示例10: _saveRessource

 /**
  * Save current DomDocument to the filesystem
  * 
  * @throws t41_Backend_Exception
  */
 protected function _saveRessource()
 {
     if (!$this->_ressource instanceof \DOMDocument) {
         throw new Exception("BACKEND_RESSOURCE_NO_RESSOURCE");
     }
     $this->_ressource->formatOutput = true;
     $this->_ressource->save($this->_path . $this->_file);
 }
开发者ID:crapougnax,项目名称:t41,代码行数:13,代码来源:XmlAdapter.php

示例11: setAttribute

function setAttribute($xmlfile, $attrName, $attrVal)
{
    $doc = new DomDocument();
    $doc->load($xmlfile);
    $elem = $doc->documentElement;
    $elem->setAttribute($attrName, $attrVal);
    // save xml file
    $doc->formatOutput = true;
    $doc->save($xmlfile);
}
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:10,代码来源:get_meta_access.php

示例12: islem

function islem()
{
    if (isset($_POST['insert'])) {
        header("Content-Type: text/html; charset=utf8");
        $get = mb_convert_case($_POST['c_name'], MB_CASE_TITLE, "UTF-8");
        $xml = simplexml_load_file("kitapdb.xml");
        foreach ($xml->KITAP as $KITAP) {
            if ($get == $KITAP->K_ADI) {
                echo '<div class="uyari">AYNI KİTABI TEKRAR ALAMAZSINIZ !</div>';
                echo '<script>setTimeout(function(){location.href="index.php"} , 3000); </script>';
                return false;
            }
        }
        header("Content-Type: text/html; charset=utf8");
        $xml = new DomDocument("1.0", "UTF-8");
        $xml->load('kitapdb.xml');
        $k = mb_convert_case($_POST['c_name'], MB_CASE_TITLE, "UTF-8");
        $y = mb_convert_case($_POST['yazar'], MB_CASE_TITLE, "UTF-8");
        $s = $_POST['sayfa_sayisi'];
        $o = mb_convert_case($_POST['ogrenci'], MB_CASE_TITLE, "UTF-8");
        $o2 = mb_convert_case($_POST['ogrenci2'], MB_CASE_TITLE, "UTF-8");
        $rootTag = $xml->getElementsByTagName('liste')->item(0);
        $infoTag = $xml->createElement("KITAP");
        $nameTag = $xml->createElement("K_ADI", $k);
        $YazarTag = $xml->createElement("YAZAR", $y);
        $SayiTag = $xml->createElement("S_SAYISI", $s);
        $OgrenciTag = $xml->createElement("OGRENCI", $o);
        $Ogrenci2Tag = $xml->createElement("OGRENCI2", $o2);
        $durum = $xml->createElement("DURUM", 1);
        $infoTag->appendChild($nameTag);
        $infoTag->appendChild($YazarTag);
        $infoTag->appendChild($SayiTag);
        $infoTag->appendChild($OgrenciTag);
        $infoTag->appendChild($Ogrenci2Tag);
        $infoTag->appendChild($durum);
        $rootTag->appendChild($infoTag);
        $xml->save('kitapdb.xml');
        echo '<script>setTimeout(function(){location.href="index.php"} , 5000); </script>';
        //MAIL GONDER
        echo '<center><h2>Kitap alma işlemi başarıyla gerçekleşti.<br>Anasayfaya yönlendiriliyorsunuz...<br> 
		<img src="loading.gif" width="32" alt=""></h2></center>';
        exit;
    }
}
开发者ID:serhatakalin,项目名称:XMLBookLibrary,代码行数:44,代码来源:func.php

示例13: file_write

function file_write()
{
    extract($GLOBALS);
    $dom = new DomDocument('1.0', 'UTF-8');
    $prefs = $dom->appendChild($dom->createElement('prefs'));
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'WinOS');
    $pref->appendChild($dom->createElement('Vista', sprintf("%d", $Vista)));
    $pref->appendChild($dom->createElement('Win7', sprintf("%d", $Win7)));
    $weekjp = array('日', '月', '火', '水', '木', '金', '土');
    $weekno = date('w');
    $week_X = "〔" . $weekjp[$weekno] . "〕";
    $pref = $prefs->appendChild($dom->createElement('pref'));
    $pref->setAttribute('code', 'DATE');
    $pref->appendChild($dom->createElement('time', date("Y年m月j日") . $week_X . date(" H時i分")));
    $pref->appendChild($dom->createElement('time_ampm', date("Y年m月j日") . $week_X . date(" A h:i")));
    $dom->formatOutput = true;
    $save_file = "/etc/zabbix/externalscripts/" . $OUT_FILE;
    $dom->save($save_file);
}
开发者ID:mintwavio,项目名称:TanpopoWeather,代码行数:20,代码来源:WinOS.php

示例14: crear

function crear()
{
    $xml = new DomDocument('1.0', 'UTF-8');
    $biblioteca = $xml->createElement('biblioteca');
    $biblioteca = $xml->appendChild($biblioteca);
    $libro = $xml->createElement('libro');
    $libro = $biblioteca->appendChild($libro);
    $autor = $xml->createElement('autor', 'Paulo Coelho');
    $autor = $libro->appendChild($autor);
    $titulo = $xml->createElement('titulo', 'El Alquimista');
    $titulo = $libro->appendChild($titulo);
    $anio = $xml->createElement('anio', '1988');
    $anio = $libro->appendChild($anio);
    $editorial = $xml->createElement('editorial', 'Maxico D.F. - Editorial Grijalbo');
    $editorial = $libro->appendChild($editorial);
    $xml->formatOutput = true;
    $el_xml = $xml->saveXML();
    $xml->save('libros.xml');
    //Mostramos el XML puro
    echo "<p><b>El XML ha sido creado.... Mostrando en texto plano:</b></p>" . htmlentities($el_xml) . "<br/><hr>";
}
开发者ID:Oskrin,项目名称:neltex_formulario,代码行数:21,代码来源:probar.php

示例15: addComment

function addComment($CommentFile, $date_value, $author_value, $subject_value, $msg_value, $ip)
{
    $xml = new DomDocument('1.0', 'utf-8');
    if (file_exists($CommentFile)) {
        $xml->load($CommentFile);
        $root = $xml->firstChild;
    } else {
        $root = $xml->appendChild($xml->createElement("comments"));
    }
    $comment = $xml->createElement("comment");
    $root->appendChild($comment);
    // Add date attribute
    $attr_date = $xml->createAttribute("timestamp");
    $comment->appendChild($attr_date);
    $value = $xml->createTextNode($date_value);
    $attr_date->appendChild($value);
    // Add author attribute
    $attr_author = $xml->createAttribute("author");
    $comment->appendChild($attr_author);
    $value = $xml->createTextNode($author_value);
    $attr_author->appendChild($value);
    // Add author ip address
    $attr_ip = $xml->createAttribute("ip");
    $comment->appendChild($attr_ip);
    $value = $xml->createTextNode($ip);
    $attr_ip->appendChild($value);
    // add subject child node
    $subject = $xml->createElement("subject");
    $comment->appendChild($subject);
    $value = $xml->createTextNode($subject_value);
    $subject->appendChild($value);
    // add message child node
    $msg = $xml->createElement("message");
    $comment->appendChild($msg);
    $value = $xml->createTextNode($msg_value);
    $msg->appendChild($value);
    $xml->save($CommentFile);
    return $xml->getElementsByTagName("comment")->length;
}
开发者ID:loveq369,项目名称:iPaintBundle,代码行数:39,代码来源:add_comment.php


注:本文中的DomDocument::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。