public function calculate() { $weight = $this->getTotalWeight() > 0 ? $this->getTotalWeight() : $this->avg_weight; $city = $this->getAddress('city') . ', ' . $this->getAddress('region'); if ($city == '') { $services = 'Не задан город'; return $services; } if (!extension_loaded('curl')) { $services = 'PHP extension CURL not loaded'; return $services; } $dom = new domDocument("1.0", "utf-8"); $root = $dom->createElement("request"); $dom->appendChild($root); $child = $dom->createElement("function", "get_delivery_price"); $root->appendChild($child); $child = $dom->createElement("api_id", $this->api_id); $root->appendChild($child); $child = $dom->createElement("from_city", $this->from_city_code_id); $root->appendChild($child); $child = $dom->createElement("to_city", $city); $root->appendChild($child); $child = $dom->createElement("pickup_place", 0); $root->appendChild($child); $child = $dom->createElement("weight", $weight); $root->appendChild($child); $child = $dom->createElement("order_price", $this->getTotalPrice()); $root->appendChild($child); $child = $dom->createElement("num", $this->avg_num); $root->appendChild($child); $child = $dom->createElement("tarifs_type", 1); $root->appendChild($child); $child = $dom->createElement("price_options", 1); $root->appendChild($child); $child = $dom->createElement("delivery_partner", $this->partner); $root->appendChild($child); $res = $this->sendRequest($dom->saveXML()); try { $xml = new SimpleXMLElement($res); } catch (Exception $e) { return 'Ошибка получения данных'; } $price = (double) $xml->price; if ($xml->error_code > 0) { return "В заданный город доставка не осуществляется"; } if ($xml->srok_dostavki != '') { $srok_dostavki = $xml->srok_dostavki . ' дн.'; } $services['sl_courier'] = array('name' => 'до дверей', 'description' => '', 'id' => 'sl_courier', 'est_delivery' => $srok_dostavki, 'rate' => $price, 'currency' => 'RUB'); return $services; }
/** * Get XML by Array * * @param array $ar * @param array $options [] * root_tag - root tag wraping body xml (example root - <root>...</root>) * format - true/false (formatting output XML) * version - XML version (<?xml version="1"?>) * encode - XML encode (<?xml encode="UTF-8"?>) * nohead - XML output without "<?xml" header * * @return string */ public static function createXML(array $ar, $options = array()) { $root_tag = isset($options['root_tag']) ? $options['root_tag'] : 'root'; $format = isset($options['format']) ? $options['format'] : true; $version = isset($options['version']) ? $options['version'] : '1.0'; $encode = isset($options['encode']) ? $options['encode'] : 'UTF-8'; $nohead = isset($options['nohead']) ? $options['nohead'] : false; $dom = new domDocument($version, $encode); $root = $dom->appendChild($dom->createElement($root_tag)); self::createXMLElement($dom, $root, $ar); $dom->formatOutput = $format; if ($nohead) { return $dom->saveXML($root); } return $dom->saveXML(); }
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); }
public function actionGetUserNotify($email) { header("Content-Type: text/xml"); $performer = 9; $notify = Notify::model()->findAll(array('condition' => 'performer_id=:performer_id', 'limit' => '3', 'params' => array(':performer_id' => $performer))); $dom = new domDocument("1.0", "cp1251"); // Создаём XML-документ версии 1.0 с кодировкой utf-8 $root = $dom->createElement("notifys"); // Создаём корневой элемент $dom->appendChild($root); foreach ($notify as $n) { $notify = $dom->createElement("notify"); $header = $dom->createElement("header", $n->header); $description = $dom->createElement("description", strip_tags($n->description)); $link = $dom->createElement("link", Notify::getCreateXmlUrl($n->route, $n->route_params)); $notify->appendChild($header); $notify->appendChild($description); $notify->appendChild($link); $root->appendChild($notify); } $import = simplexml_import_dom($dom); echo $import->asXML(); }
<?php include_once "config.php"; $corp = $_GET["corp"]; //$corp= $_COOKIE['corp']; $result = mysqli_query($db, "\n\tSELECT id, NumberAudit, Corps_id, Type, TableType, Capacity, Area, Conditioner, CountSeats, Sockets\n\tFROM Auditorium\n\tWHERE Corps_id='{$corp}'\n\t"); $result2 = mysqli_query($db, "\n\tSELECT Abbr, ext_id\n\tFROM Corps\n\tWHERE id='{$corp}'\n\t"); $res2 = mysqli_fetch_array($result2); $dom = new domDocument("1.0", "windows-1251"); // Создаём XML-документ версии 1.0 с кодировкой windows-1251 $Data_Root = $dom->appendChild($dom->createElement('Data_Root')); $Descript = $Data_Root->appendChild($dom->createElement('Descript')); $Descript->setAttribute("ExpSet_Code", '014'); $Descript->setAttribute("ExpSet_Name", 'Auditorium'); $Descript->appendChild($dom->createCDATASection('')); $Data = $Data_Root->appendChild($dom->createElement('Data')); $Collection = $Data->appendChild($dom->createElement('Collection')); $Collection->setAttribute("caption", 'Аудитории'); $Collection->setAttribute("name", 'Data.Auditorium'); $Collection->setAttribute("child_tags", 'Object'); while ($res = mysqli_fetch_array($result)) { $auditor_id = $res[0]; $num_audit = $res[1]; $abbr_corp = $res2[0]; $ext_id_corp = $res2[1]; $capasity_audit = $res[5]; $type_audit = $res[3]; $square_audit = $res[6]; $table_type = $res[4]; $conditioner = $res[7]; $result3 = mysqli_query($db, "\n\t\tSELECT Amount\n\t\tfrom Auditorium_Equipment\n\t\twhere Auditorium_id='{$auditor_id}' and Equipment_id=1\n\t");
<?php include '../Config/db.php'; header("content-type: text/xml"); $dom = new domDocument("1.0", "CP1251"); $root = $dom->createElement("Orders"); $dom->appendChild($root); $query = mysql_query(@"SELECT\n orders.*,\n users.name,\n users.email,\n users.phone,\n users.company,\n warehouses.keycode AS wh_key,\n pricetypes.keycode AS pt_key\n FROM orders\n LEFT JOIN users ON orders.user_id = users.id\n LEFT JOIN warehouses ON users.wh_id = warehouses.id\n LEFT JOIN pricetypes ON users.pt_id = pricetypes.id\n WHERE orders.status = 1 AND orders.sync = 0"); while ($do = mysql_fetch_array($query)) { $order = $dom->createElement("Order"); $number = $dom->createElement("Number", $do['id']); $wh = $dom->createElement("WH", $do['wh_key']); $pt = $dom->createElement("PT", $do['pt_key']); $clientID = $dom->createElement("ClientID", $do['user_id']); $clientName = $dom->createElement("ClientName", $do['name']); $clientCompany = $dom->createElement("Company", $do['company']); $email = $dom->createElement("Email", $do['email']); $phone = $dom->createElement("Phone", $do['phone']); $comment = $dom->createElement("Comment", $do['comment']); $products = $dom->createElement("Products"); $pquery = mysql_query("SELECT cart.*, products.keycode, categories.expected FROM cart LEFT JOIN products ON cart.product_id = products.id LEFT JOIN categories ON products.category_id = categories.id WHERE order_id = '" . $do['id'] . "'"); while ($pdo = mysql_fetch_array($pquery)) { $product = $dom->createElement("Product"); $article = $dom->createElement("Key", $pdo['keycode']); $quantity = $dom->createElement("Quantity", $pdo['quantity']); $price = $dom->createElement("Price", $pdo['price']); $expected = $dom->createElement("ThisExpected", $pdo['expected']); $product->appendChild($article); $product->appendChild($quantity); $product->appendChild($price); $product->appendChild($expected);
<SET_OF_RELATED_PATTERNS> </SET_OF_RELATED_PATTERNS> <PATTERN_IDENTIFICATION> </PATTERN_IDENTIFICATION> </Patern>'; $doc = new domDocument(); $doc->loadXML($anXMLString); $key = key($resultQuery); $val = current($resultQuery); $nbrValues = count($resultQuery); while (list($key, $val) = each($resultQuery)) { if (!is_array($val)) { switch ($key) { case $key == 'pattern_name': $newnode = $doc->createElement($key, $val); $doc->appendChild($newnode); $add = $doc->getElementsByTagName('GENERAL')->item(0); $add->appendChild($newnode); break; case $key == 'pattern_abstract': $newnode = $doc->createElement($key, $val); $doc->appendChild($newnode); $add = $doc->getElementsByTagName('GENERAL')->item(0); $add->appendChild($newnode); break; case $key == 'pattern_desc': $newnode = $doc->createElement($key, $val); $doc->appendChild($newnode); $add = $doc->getElementsByTagName('GENERAL')->item(0); $add->appendChild($newnode); break;
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; }
$day[$count] = $attr4[$count]['day']; $low[$count] = $attr4[$count]['low']; $high[$count] = $attr4[$count]['high']; $text1[$count] = $attr4[$count]['text']; //echo "result here".$day[$count]; $count++; } } /************************************************create xml********************************************/ try { /*** a new dom object ***/ $dom = new domDocument(); /*** make the output tidy ***/ $dom->formatOutput = true; /*** create the root element ***/ $root = $dom->appendChild($dom->createElement("weather")); /*** create the simple xml element ***/ $sxe = simplexml_import_dom($dom); /*** add a feed element ***/ $sxe->addChild("feed", $url_weather); /*** add a link element ***/ $sxe->addChild("link", $link); /*** add a location element ***/ $loc = $sxe->addChild("location"); /*** add attributes ***/ $loc->addAttribute("city", $city); $loc->addAttribute("region", $region); $loc->addAttribute("country", $country); /*** add a unit element***/ $uni = $sxe->addChild("units"); /*** add attributes ***/
<?php error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); $dom = new domDocument("1.0", "utf-8"); // Создаём XML-документ версии 1.0 с кодировкой utf-8 $root = $dom->createElement("rss"); // Создаём корневой элемент $root->setAttribute("version", "2.0"); $dom->appendChild($root); $chanel = $dom->createElement("channel"); $dom->appendChild($chanel); $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);
<?php $document = new domDocument("1.0", "utf-8"); $domimp = new domImplementation(); $doctype = $domimp->createDocumentType('asortiment[<!ENTITY y1 "2009"> <!ENTITY y2 "2010">]'); $document->appendChild($doctype); $asortiment = $document->createElementNS("http://mysite.ru", "asort:asortiment"); $document->appendChild($asortiment); $telefon = $document->createElement("asort:telefon"); $asortiment->appendChild($telefon); $attr = $document->createAttribute("number"); $attr->nodeValue = 1; $telefon->appendChild($attr); $cdata = $document->createCDATASection("Это контент нашего интернет магазина"); $telefon->appendChild($cdata); $model_1 = $document->createElement("model"); $telefon->appendChild($model_1); $name_1 = $document->createElement("name"); $model_1->appendChild($name_1); $textN_1 = $document->createTextNode("Samsung Galaxi"); $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"); $telefon->appendChild($model_2); $name_2 = $document->createElement("name"); $model_2->appendChild($name_2); $textN_2 = $document->createTextNode("Nokia Lumia"); $name_2->appendChild($textN_2);
/** * * @get text between tags * @param string $tag The tag name * @param string $html The XML or XHTML string * @param int $strict Whether to use strict mode * @param string $encoding * @return array */ private function getTextBetweenTags($tag, $html, $strict = 0, $encoding = "UTF-8") { global $PAGE, $CFG; if (!isset($CFG->filter_jsxgraph_divid)) { set_config('filter_jsxgraph_divid', 'box'); } if (!isset($CFG->filter_jsxgraph_boardvar)) { set_config('filter_jsxgraph_boardvar', 'board'); } if (!isset($CFG->filter_jsxgraph_width)) { set_config('filter_jsxgraph_width', '500'); } if (!isset($CFG->filter_jsxgraph_height)) { set_config('filter_jsxgraph_height', '400'); } // a new dom object $dom = new domDocument(); $dom->formatOutput = true; // load the html into the object if ($strict == 1) { $dom->loadXML($html); } else { libxml_use_internal_errors(true); $htmlutf8 = mb_convert_encoding($html, 'HTML-ENTITIES', $encoding); $dom->loadHTML($htmlutf8); libxml_use_internal_errors(false); } // discard white space $dom->preserveWhiteSpace = false; $dom->strictErrorChecking = false; $dom->recover = true; // the tag by its tag name $content = $dom->getElementsByTagname($tag); if (count($content) > 0) { $PAGE->requires->js(new moodle_url($CFG->wwwroot . '/filter/jsxgraph/jsxgraphcore.js')); } // Iterate backwards through the jsxgraph tags $i = $content->length - 1; while ($i > -1) { $item = $content->item($i); // Read attributes $w = $item->getAttribute('width'); if ($w == "") { $w = $CFG->filter_jsxgraph_width; } $h = $item->getAttribute('height'); if ($h == "") { $h = $CFG->filter_jsxgraph_height; } $b = $item->getAttribute('box'); if ($b == "") { $b = $CFG->filter_jsxgraph_divid . $i; } $brd = $item->getAttribute('board'); if ($brd == "") { $brd = $CFG->filter_jsxgraph_boardvar . $i; } /* Create new div element containing JSXGraph */ $out = $dom->createElement('div'); $a = $dom->createAttribute('id'); $a->value = $b; $out->appendChild($a); $a = $dom->createAttribute('class'); $a->value = "jxgbox"; $out->appendChild($a); $a = $dom->createAttribute('style'); $a->value = "width:" . $w . "px; height:" . $h . "px; "; $out->appendChild($a); $t = $dom->createTextNode(""); $out->appendChild($t); $out = $dom->appendChild($out); // Replace <jsxgraph> by <div> $item->parentNode->replaceChild($out, $item); $code = ""; $needGXT = false; $url = $item->getAttribute('file'); if ($url != "") { $code = "var " . $brd . " = JXG.JSXGraph.loadBoardFromFile('" . $b . "', '" . $url . "', 'Geonext');"; $needGXT = true; } else { $url = $item->getAttribute('filestring'); if ($url != "") { $code = "var " . $brd . " = JXG.JSXGraph.loadBoardFromString('" . $b . "', '" . $url . "', 'Geonext');"; $needGXT = true; } else { // Plain JavaScript code $code = $item->nodeValue; } } // Place JavaScript code at the end of the page. $PAGE->requires->js_init_call($code); if ($needGXT) { $PAGE->requires->js(new moodle_url($CFG->wwwroot . '/filter/jsxgraph/GeonextReader.js')); } --$i; } // remove DOCTYPE $dom->removeChild($dom->firstChild); // remove <html><body></body></html> //$dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); //return $dom->saveXML(); $str = $dom->saveHTML(); $str = str_replace("<body>", "", $str); $str = str_replace("</body>", "", $str); $str = str_replace("<html>", "", $str); $str = str_replace("</html>", "", $str); return $str; }
public function request($arg) { $site = litepublisher::$site; $s = '<?php turlmap::sendxml(); ?>'; switch ($arg) { case 'manifest': $s .= '<manifest xmlns="http://schemas.microsoft.com/wlw/manifest/weblog">' . '<options>' . '<clientType>WordPress</clientType>' . '<supportsKeywords>Yes</supportsKeywords>' . '<supportsGetTags>Yes</supportsGetTags>' . '<supportsNewCategories>Yes</supportsNewCategories>' . '</options>' . '<weblog>' . '<serviceName>Lite Publisher</serviceName>' . "<homepageLinkText>{$site->name}</homepageLinkText>" . "<adminLinkText>{$site->name}</adminLinkText>" . "<adminUrl>{$site->url}/admin/</adminUrl>" . '<postEditingUrl>' . "<![CDATA[{$site->url}/admin/posts/editor/{$site->q}id={post-id}]]>" . '</postEditingUrl>' . '</weblog>' . '<buttons>' . '<button>' . '<id>0</id>' . '<text>Manage Comments</text>' . '<imageUrl>/favicon.ico</imageUrl>' . '<clickUrl>' . "<![CDATA[{$site->url}/admin/comments/]]>" . '</clickUrl>' . '</button>' . '</buttons>' . '</manifest>'; break; case 'rsd': /* $s .= '<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">' . '<service>' . '<engineName>Lite Publisher</engineName>' . '<engineLink>http://litepublisher.com/</engineLink>' . "<homePageLink>$site->url/</homePageLink>" . '<apis>' . '<api name="WordPress" blogID="1" preferred="true" apiLink="' . $site->url . '/rpc.xml" />' . '<api name="Movable Type" blogID="1" preferred="false" apiLink="' . $site->url . '/rpc.xml" />' . '<api name="MetaWeblog" blogID="1" preferred="false" apiLink="' . $site->url . '/rpc.xml" />' . '<api name="Blogger" blogID="1" preferred="false" apiLink="' . $site->url . '/rpc.xml" />' . '</apis>' . '</service>' . '</rsd>'; */ $dom = new domDocument(); $dom->encoding = 'utf-8'; $rsd = $dom->createElement('rsd'); $dom->appendChild($rsd); tnode::attr($rsd, 'version', '1.0'); tnode::attr($rsd, 'xmlns', 'http://archipelago.phrasewise.com/rsd'); $service = tnode::add($rsd, 'service'); tnode::addvalue($service, 'engineName', 'LitePublisher'); tnode::addvalue($service, 'engineLink', 'http://litepublisher.com/'); tnode::addvalue($service, 'homePageLink', litepublisher::$site->url . '/'); $apis = tnode::add($service, 'apis'); $api = tnode::add($apis, 'api'); tnode::attr($api, 'name', 'WordPress'); tnode::attr($api, 'blogID', '1'); tnode::attr($api, 'preferred', 'true'); tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml'); $api = tnode::add($apis, 'api'); tnode::attr($api, 'name', 'Movable Type'); tnode::attr($api, 'blogID', '1'); tnode::attr($api, 'preferred', 'false'); tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml'); $api = tnode::add($apis, 'api'); tnode::attr($api, 'name', 'MetaWeblog'); tnode::attr($api, 'blogID', '1'); tnode::attr($api, 'preferred', 'false'); tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml'); $api = tnode::add($apis, 'api'); tnode::attr($api, 'name', 'Blogger'); tnode::attr($api, 'blogID', '1'); tnode::attr($api, 'preferred', 'false'); tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml'); $xml = $dom->saveXML(); $s .= substr($xml, strpos($xml, '?>') + 2); break; } return $s; }
public function generateRss() { $xml_par = $this->getXml(); $xml_version = $xml_par['version']; $xml_charset = $xml_par['charset']; $xml = new domDocument($xml_version, $xml_charset); $rss = $xml->createElement('rss'); //rss foreach ($this->getRss() as $key => $value) { $rss->setAttribute($key, $value); } $xml->appendChild($rss); //channel $channel = $xml->createElement('channel'); foreach ($this->channel as $key => $value) { $row = $xml->createElement($key, $value['val']); if (!empty($value['attr'])) { foreach ($value['attr'] as $attr_key => $attr_val) { $row->setAttribute($attr_key, $attr_val); } } $channel->appendChild($row); } $rss->appendChild($channel); foreach ($this->items as $item_key => $item) { $item_element = $xml->createElement('item'); foreach ($item as $key => $value) { $row = $xml->createElement($key, $value['val']); if (!empty($value['attr'])) { foreach ($value['attr'] as $attr_key => $attr_val) { $row->setAttribute($attr_key, $attr_val); } } $item_element->appendChild($row); } $channel->appendChild($item_element); } return $xml->saveXML(); }
$cdata_2 = new domCdataSection("Section CDATA 2"); echo $cdata_1->nodeValue . "<br/>"; echo $cdata_2->nodeValue . "<br/>"; echo "---------------------------------------*<br/>"; $text_1 = $document->createTextNode("Text Node 1"); $text_2 = new domText("Text Node 2"); echo $text_1->nodeValue . "<br/>"; echo $text_2->nodeValue . "<br/>"; 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);