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


PHP domDocument::save方法代码示例

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


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

示例1: addModel

function addModel($node)
{
    $document = new domDocument("1.0", "utf-8");
    $document->load("test3.xml");
    if ($node == "telefon") {
        $nameEl = "Телефон";
    }
    if ($node == "noutbuk") {
        $nameEl = "Ноутбук";
    }
    if ($node == "printer") {
        $nameEl = "Принтер";
    }
    if ($_POST["marka"] != "" && $_POST["year"] != "") {
        $element = $document->getElementsByTagName($node)->item(0);
        $model = $document->createElement("model");
        $element->appendChild($model);
        $name = $document->createElement("name", $_POST["marka"]);
        $model->appendChild($name);
        $year = $document->createElement("year", $_POST["year"]);
        $model->appendChild($year);
        $document->save("test3.xml");
        echo "<p style='padding:10px; background:#C3FFD2;'>" . $nameEl . " Удачно добавлен!</p>";
    } else {
        echo "<p style='padding:10px; background:#FFF0F0;'>Не удалось добавить " . $nameEl . ", так как не все поля были заполнены!</p>";
    }
}
开发者ID:echmaster,项目名称:data,代码行数:27,代码来源:dz.php

示例2: addUser

		public function addUser(){
			$document = new domDocument();
			$document->load("users/users.xml");
			$root = $document->getElementsByTagName("users")->item(0);
			$user = $root->appendChild(new domElement("user"));
			$user->appendChild($document->createElement("login", "$this->login"));
			$user->appendChild($document->createElement("password","$this->pass"));
			$document->save("users/users.xml");
		}
开发者ID:echmaster,项目名称:data,代码行数:9,代码来源:User.php

示例3: xmlSave

 function xmlSave($xmlfilename)
 {
     $dom = new domDocument();
     /*
         $complexe = $dom->appendChild(new DOMElement('complexe'));
         $reel = $complexe->appendChild(new DOMElement('reel'));
         $imag = $complexe->appendChild(new DOMElement('imag'));
         $reel->nodeValue=1;
         $imag->nodeValue=2;
     */
     $complexe = $dom->CreateElement('complexe');
     $dom->appendChild($complexe);
     $reel = $dom->CreateElement('reel', 1);
     $imag = $dom->CreateElement('imag', 2);
     $complexe->appendChild($reel);
     $complexe->appendChild($imag);
     // ToDo sérialisation XML
     print $dom->saveXML();
     $dom->save($xmlfilename);
 }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:20,代码来源:index.php

示例4: header

    $prop_value = $Collection2->appendChild($dom->createElement('prop_value'));
    $prop_value->setAttribute("prop_name", 'Note');
    $prop_value->setAttribute("value", '');
    $dom->formatOutput = true;
}
// $logins = array("User1", "User2", "User3"); // Логины пользователей
// $passwords = array("Pass1", "Pass2", "Pass3"); // Пароли пользователей
// for ($i = 0; $i < count($logins); $i++) {
//   $id = $i + 1; // id-пользователя
//   $user = $dom->createElement("user"); // Создаём узел "user"
//   $user->setAttribute("id", $id); // Устанавливаем атрибут "id" у узла "user"
//   $login = $dom->createElement("login", $logins[$i]); // Создаём узел "login" с текстом внутри
//   $password = $dom->createElement("password", $passwords[$i]); // Создаём узел "password" с текстом внутри
//   $user->appendChild($login); // Добавляем в узел "user" узел "login"
//   $user->appendChild($password);// Добавляем в узел "user" узел "password"
//   $root->appendChild($user); // Добавляем в корневой узел "users" узел "user"
// }
$dom->save("Auditorium.xml");
// Сохраняем полученный XML-документ в файл
$file = 'Auditorium.xml';
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    readfile($file);
    exit;
}
开发者ID:Ksysha,项目名称:audit,代码行数:31,代码来源:download.php

示例5: while

            case $key == 'objectives':
                $newnode = $doc->createElement($key, $val2);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('SET_OF_SOLUTIONS')->item(0);
                $add->appendChild($newnode);
                break;
                //********************************************************************************
            //********************************************************************************
            case $key == 'relatedPatterns':
                while (list($key2, $val2) = each($newval)) {
                    $newnode = $doc->createElement($key, $val2);
                    $doc->appendChild($newnode);
                    $add = $doc->getElementsByTagName('SET_OF_RELATED_PATTERNS')->item(0);
                    $add->appendChild($newnode);
                }
                break;
                //**********************patern Identification******************
            //**********************patern Identification******************
            case $key == 'autors':
                $newnode = $doc->createElement($key, $val2);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('PATTERN_IDENTIFICATION')->item(0);
                $add->appendChild($newnode);
                break;
        }
    }
}
$doc->save(XML_PATH . 'myxml.xml');
$res = $doc->saveXML();
print $res;
echo "file created";
开发者ID:laiello,项目名称:dp-navigator,代码行数:31,代码来源:createXml7.php

示例6: save_db

function save_db($root, $saveXml)
{
    $dom = new domDocument();
    $dom->loadXML($saveXml->asXML());
    $dom->save($root . "db/fitzroydb.xml");
}
开发者ID:Haynesy,项目名称:FitzroyRotary,代码行数:6,代码来源:config.php

示例7: xml

 protected function xml($datafeed, $filename)
 {
     $this->load->helper('download');
     $dom = new domDocument("1.0", "utf-8");
     $root = $dom->createElement("items");
     $dom->appendChild($root);
     foreach ($datafeed as $feed) {
         if ($feed->ic_id == "") {
             continue;
         }
         $feed->ic_retail_price = trim($feed->ic_retail_price) == '' || $feed->ic_retail_price == 0 ? $feed->ic_price * 3 : $feed->ic_retail_price;
         $item = $dom->createElement("item");
         $item->setAttribute("id", $feed->ic_id);
         $params = array();
         $params['SKU'] = $dom->createElement("SKU", $feed->SKU);
         $params['Barcode'] = $dom->createElement("Barcode", $feed->upc_ean);
         $params['Manufacturer_Part_Number'] = $dom->createElement("Manufacturer_Part_Number", $feed->manuf_num);
         $params['Manufacturer_Name'] = $dom->createElement("Manufacturer_Name", $feed->m_name);
         $params['Brand_Name'] = $dom->createElement("Brand_Name", $feed->b_name);
         $params['Title'] = $dom->createElement("Title", $feed->tr_title);
         $params['Description'] = $dom->createElement("Description", htmlspecialchars(strip_tags($feed->tr_desc)));
         $params['Category_ID'] = $dom->createElement("Category_ID", $feed->c_id);
         $params['Category_Name'] = $dom->createElement("Category_Name", htmlspecialchars($this->getFullCategoryName($feed->c_id)));
         $params['Weight'] = $dom->createElement("Weight", $feed->weight + " " + $feed->weightScale);
         $params['Ship_Alone'] = $dom->createElement("Ship_Alone", $feed->ship_alone);
         $params['Height'] = $dom->createElement("Height", $feed->d_height + " " + $feed->d_scale);
         $params['Width'] = $dom->createElement("Width", $feed->d_width + " " + $feed->d_scale);
         $params['Depth'] = $dom->createElement("Depth", $feed->d_dept + " " + $feed->d_scale);
         $params['LeadTime'] = $dom->createElement("LeadTime", $feed->ic_leadtime);
         $params['Quantity_In_Stock'] = $dom->createElement("Quantity_In_Stock", $feed->ic_quan);
         $params['Selling_Price'] = $dom->createElement("Selling_Price", $feed->ic_price);
         $params['MSRP'] = $dom->createElement("MSRP", $feed->ic_retail_price);
         $params['Promo_Text'] = $dom->createElement("Promo_Text", $feed->ic_prom_text);
         $params['MAP'] = $dom->createElement("MAP", $feed->ic_map);
         $params['Shipping_Cost'] = $dom->createElement("Shipping_Cost", $feed->ic_ship_cost);
         $params['Min_Order'] = $dom->createElement("Min_Order", $feed->ic_min_order);
         $params['Case_Pack'] = $dom->createElement("Case_Pack", $feed->ic_case_pack);
         $this->load->model('inventories');
         $image_list = $this->inventories->list_image($feed->i_id);
         $images = $dom->createElement("images");
         foreach ($image_list as $image) {
             $pic_name = $dom->createElement("image", "http://shop.oceantailer.com/" . $image->ii_link);
             $images->appendChild($pic_name);
         }
         foreach ($params as $param) {
             $item->appendChild($param);
         }
         $item->appendChild($images);
         $root->appendChild($item);
     }
     $dom->save($filename);
     return;
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:53,代码来源:buyers_cron.php

示例8: while

$root->appendChild($chanel);
$title = $dom->createElement("title", "Лента сайта WEIRD WORLD");
$dom->appendChild($title);
$chanel->appendChild($title);
$link = $dom->createElement("link", "http://weird-world.ru");
$dom->appendChild($link);
$chanel->appendChild($link);
$description = $dom->createElement("description", "Описание");
$dom->appendChild($description);
$chanel->appendChild($description);
include "../include/connection.php";
$result = mysql_query("SELECT * FROM articles WHERE visible='1'", $db);
if (mysql_num_rows($result) > 0) {
    do {
        $item = $dom->createElement("item");
        $dom->appendChild($item);
        $chanel->appendChild($item);
        $title = $dom->createElement("title", htmlspecialchars_decode($row["title"]));
        $dom->appendChild($title);
        $item->appendChild($title);
        $link = $dom->createElement("link", "http://weird-world.ru/view.php?id=" . $row["article_id"]);
        $dom->appendChild($link);
        $item->appendChild($link);
        $description = $dom->createElement("description", htmlspecialchars_decode(substr($row['text'], 0, 900)));
        $dom->appendChild($description);
        $item->appendChild($description);
    } while ($row = mysql_fetch_array($result));
}
$dom->save("rss.xml");
// Сохраняем полученный XML-документ в файл
echo "+";
开发者ID:VitaAprel,项目名称:easytesting,代码行数:31,代码来源:feedparse.php

示例9: htmlspecialchars

$year_3 = $document->createElement("year");
$model_3->appendChild($year_3);
$textY_3 = $document->createTextNode('2009');
$year_3->appendChild($textY_3);
$printer = $document->createElementNS("http://php.loc", "printer");
$asortiment->appendChild($printer);
$attr->nodeValue = 3;
$printer->appendChild($attr);
$model_1 = $document->createElement("model");
$printer->appendChild($model_1);
$name_1 = $document->createElement("name");
$model_1->appendChild($name_1);
$textN_1 = $document->createTextNode("Canon");
$name_1->appendChild($textN_1);
$year_1 = $document->createElement("year");
$model_1->appendChild($year_1);
$textY_1 = $document->createTextNode('2009');
$year_1->appendChild($textY_1);
$model_2 = $document->createElement("model");
$printer->appendChild($model_2);
$name_2 = $document->createElement("name");
$model_2->appendChild($name_2);
$textN_2 = $document->createTextNode("HP VX3510");
$name_2->appendChild($textN_2);
$year_2 = $document->createElement("year");
$model_2->appendChild($year_2);
$textY_2 = $document->createTextNode('2010');
$year_2->appendChild($textY_2);
echo htmlspecialchars($document->saveXML());
$document->save("test2.xml");
开发者ID:echmaster,项目名称:data,代码行数:30,代码来源:dz.php

示例10: timeInterval2Days

        $node = $newHelioResult->importNode($node, true);
        // Et on l'ajoute dans le le noeud racine "<MDES>"
        $newHelioResult->documentElement->appendChild($node);
    }
}
$newHelioResult->save("helioResult.xml");
// Transformation in VOtable
$xslt = new XSLTProcessor();
// Chargement du fichier XSL
$xsl = new domDocument();
$xsl->load(XML_BASE_DIR . "/xml2votMulti.xsl");
// Import de la feuille XSL
$xslt->importStylesheet($xsl);
$vot = new domDocument();
$vot->loadXML($xslt->transformToXML($newHelioResult));
$vot->save("VOT.xml");
if (Verbose) {
    fclose(log);
}
function timeInterval2Days($TimeInterval)
{
    // Calculating number of Days, Hours, Min & Sec in interval
    $divDays = 60 * 60 * 24;
    $nbDays = floor($TimeInterval / $divDays);
    $divHours = 60 * 60;
    $nbHours = floor(($TimeInterval - $divDays * $nbDays) / $divHours);
    $nbMin = floor(($TimeInterval - $divDays * $nbDays - $divHours * $nbHours) / 60);
    $nbSec = $TimeInterval - $divDays * $nbDays - $divHours * $nbHours - $nbMin * 60;
    // Transforming Integers to String with special format
    $DD = sprintf("%03s", (string) $nbDays);
    // format ex. 005 not 5
开发者ID:helio-vo,项目名称:helio,代码行数:31,代码来源:multiRequest_new.php

示例11: htmlspecialchars

echo "---------------------------------------*<br/>";
$comment_1 = $document->createComment("Comment 1");
$comment_2 = new domComment("Comment 2");
echo $comment_1->nodeValue . "<br/>";
echo $comment_2->nodeValue . "<br/>";
echo "<br/>*---------------------------------------*<br/><br/>";
$comment = $document->createComment("This is document");
$document->appendChild($comment);
$root = $document->createElement("root");
$document->appendChild($root);
$element1 = $document->createElement("el1");
$element2 = $document->createElement("el2");
$root->appendChild($element1);
$root->appendChild($element2);
$text1 = $document->createTextNode("Text 1");
$text2 = $document->createTextNode("Text 2");
$element1->appendChild($text1);
$element2->appendChild($text2);
$attr = $document->createAttribute("attr");
$attr->nodeValue = 20;
$root->appendChild($attr);
$cdata = $document->createCdataSection("<cdata>Section</cdata>");
$root->appendChild($cdata);
/*$root->insertBefore(new domElement("el3"), $element2);
	$root->replaceChild(new domElement("el4"), $element1);*/
$root->removeChild($element1);
$element2->removeChild($text2);
$root->removeAttributeNode($attr);
echo htmlspecialchars($document->saveXML());
$document->save("createXml.xml");
开发者ID:echmaster,项目名称:data,代码行数:30,代码来源:14+Создание+XML-документа+в+PHP.php


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