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


PHP DOMDocument::appendChild方法代码示例

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


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

示例1: __construct

 /**
  * The Construct
  *
  * @param  string $filename
  * @param  arrray $arguments
  *
  * @return SiteQ_Report_AbstractReport
  */
 public function __construct($filename, $arguments)
 {
     parent::__construct($filename, $arguments);
     $this->_document = new DOMDocument();
     $this->_root = $this->_document->createElement('siteq');
     $this->_document->appendChild($this->_root);
 }
开发者ID:hpbuniat,项目名称:SiteQ,代码行数:15,代码来源:Xml.php

示例2: __construct

 /**
  * Constructor
  * 
  * @return void
  * @access public
  * @since 1/17/08
  */
 public function __construct()
 {
     $this->doc = new Harmoni_DOMDocument('1.0', 'UTF-8');
     $this->doc->appendChild($this->doc->createElement('rss'));
     $this->doc->documentElement->setAttribute('version', "2.0");
     $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:excerpt', 'http://wordpress.org/export/1.1/excerpt/');
     $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:content', 'http://purl.org/rss/1.0/modules/content/');
     $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:wfw', 'http://wellformedweb.org/CommentAPI/');
     $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:wp', 'http://wordpress.org/export/1.1/');
     $this->channel = $this->doc->documentElement->appendChild($this->doc->createElement('channel'));
     // create some comment placeholders for organizing our elements
     $this->channel->appendChild($this->doc->createComment("Begin - Meta"));
     $this->endMeta = $this->channel->appendChild($this->doc->createComment("End - Meta"));
     $this->channel->appendChild($this->doc->createComment("Begin - Authors"));
     $this->endAuthors = $this->channel->appendChild($this->doc->createComment("End - Authors"));
     $this->channel->appendChild($this->doc->createComment("Begin - Categories"));
     $this->endCategories = $this->channel->appendChild($this->doc->createComment("End - Categories"));
     $this->channel->appendChild($this->doc->createComment("Begin - Tags"));
     $this->endTags = $this->channel->appendChild($this->doc->createComment("End - Tags"));
     $this->channel->appendChild($this->doc->createComment("Begin - Files"));
     $this->endFiles = $this->channel->appendChild($this->doc->createComment("End - Files"));
     $this->channel->insertBefore($this->getElement('generator', 'http://segue.middlebury.edu/'), $this->endMeta);
     $this->xpath = new DOMXPath($this->doc);
     $this->xpath->registerNamespace('wp', 'http://wordpress.org/export/1.1/');
 }
开发者ID:adamfranco,项目名称:segue,代码行数:33,代码来源:WordpressExportSiteVisitor.class.php

示例3: prepare

 /**
  * {@inheritdoc}
  */
 public function prepare()
 {
     $this->xml = new \DOMDocument();
     $this->rootNode = $this->xml->createElement($this->rootNodeName);
     $this->xml->appendChild($this->rootNode);
     return $this;
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:10,代码来源:XmlWriter.php

示例4: build

 public function build()
 {
     $this->doc = new \DOMDocument('1.0', 'UTF-8');
     if ($this->structure) {
         $this->doc->appendChild($this->doc->importNode(dom_import_simplexml($this->structure), true));
     }
 }
开发者ID:energine-cmf,项目名称:energine,代码行数:7,代码来源:PageStructureDocument.php

示例5: generateXML

 /**
  * @param DOMDocument $documentXml
  * @param DOMDocument $parent
  */
 public function generateXML($documentXml, $parent)
 {
     if ($this->getType() == EiDataSetStructure::$TYPE_NODE) {
         $element = $documentXml->createElement($this->getEiDataSetStructure()->getXMLTag());
         /** @var Doctrine_Node_NestedSet $node */
         $node = $this->getNode();
         /** @var EiTestSetDataSet[] $descendants */
         $descendants = $node->getDescendants(1);
         if ($descendants !== false) {
             /** @var EiTestSetDataSet $leaf */
             foreach ($descendants as $leaf) {
                 if ($leaf->getType() == EiDataSetStructure::$TYPE_LEAF) {
                     $leaf->generateXML($documentXml, $element);
                 }
             }
         }
         $parent->appendChild($element);
         if ($descendants !== false) {
             // On parcours les fils.
             /** @var EiNodeDataSet $child */
             foreach ($node->getDescendants(1) as $child) {
                 if ($child->getType() == EiDataSetStructure::$TYPE_NODE) {
                     // On génère l'élément XSD relatif au noeud fils.
                     $child->generateXML($documentXml, $element);
                 }
             }
         }
     } else {
         $element = $documentXml->createElement($this->getEiDataSetStructure()->getXMLTag(), htmlspecialchars($this->getValue()));
         $parent->appendChild($element);
     }
 }
开发者ID:lendji4000,项目名称:compose,代码行数:36,代码来源:EiTestSetDataSet.class.php

示例6:

 /**
  * Creates a new xml sitemag generator
  */
 function __construct()
 {
     $this->domDoc = new \DOMDocument("1.0", "utf-8");
     $this->domDoc->formatOutput = true;
     $this->CreateUrlset();
     $this->domDoc->appendChild($this->urlset);
 }
开发者ID:agentmedia,项目名称:phine-framework,代码行数:10,代码来源:XmlGenerator.php

示例7: run

 /**
  *
  */
 public function run()
 {
     $nRecords = mysqli_query($this->conn, 'SELECT COUNT(*) AS `qty` FROM `data`;')->fetch_object()->qty;
     $xml = new DOMDocument("1.0");
     $xml->formatOutput = true;
     $xml->encoding = 'UTF-8';
     $root = $xml->appendChild(new DOMElement('records'));
     $pBar = new ProgressBar($nRecords);
     $totalCost = 0;
     $offset = 0;
     while ($offset < $nRecords) {
         $record = mysqli_query($this->conn, 'SELECT * FROM `data` LIMIT 1 OFFSET ' . $offset)->fetch_assoc();
         $pid = $record['product_id'];
         $xmlRecord = $root->appendChild(new DOMElement('record'));
         $xmlRecord->setAttribute('id', $record['id']);
         $xmlRecord->appendChild(new DOMElement('product_id', $pid));
         $xmlRecord->appendChild(new DOMElement('cost', $record['cost']));
         $product = $this->getRecord($pid);
         $productRatio = isset($product['product_ratio']) ? $product['product_ratio'] : 0;
         $familyRatio = isset($product['family_ratio']) ? $product['family_ratio'] : 0;
         $realCost = $record['cost'] * $productRatio * $familyRatio;
         $xmlRecord->appendChild(new DOMElement('relative_cost', $realCost));
         $xmlRecord->appendChild(new DOMElement('product_name', $product['product_name']));
         $xmlRecord->appendChild(new DOMElement('family_id', $product['family_id']));
         $xmlRecord->appendChild(new DOMElement('family_name', $product['family_name']));
         $totalCost += $realCost;
         $offset++;
         $pBar->updateValue($offset);
     }
     print "\n";
     $xml->appendChild(new DOMElement('total_cost', $totalCost));
     print $xml->saveXML();
     print sprintf("this script lasted %d seconds !\n", intval(date("U") - $this->startTime));
 }
开发者ID:jlaso,项目名称:PreEmptiveCache,代码行数:37,代码来源:sample-unoptimized.php

示例8: saveXML

 /**
  * Recuperer la configuration au format XML.
  */
 public function saveXML()
 {
     $existing = array();
     $attributes = $this->domdocument->getElementsByTagName('attribute');
     foreach ($attributes as $attribute) {
         $existing[$attribute->getAttribute('name')] = $attribute;
     }
     if ($this->domdocument->getElementsByTagName('config')->item(0) == null) {
         $root = $this->domdocument->createElement('config');
         $this->domdocument->appendChild($root);
     } else {
         $root = $this->domdocument->getElementsByTagName('config')->item(0);
     }
     foreach ($this->config as $attribute => $value) {
         if (array_key_exists($attribute, $existing)) {
             $node = $existing[$attribute];
         } else {
             $node = $this->domdocument->createElement('attribute');
             $root->appendChild($node);
             $node->setAttribute('name', $attribute);
         }
         $node->setAttribute('value', $value);
     }
     $configNodes = $root->getElementsByTagName('attribute');
     foreach ($configNodes as $node) {
         if (!array_key_exists($node->getAttribute('name'), $this->config)) {
             $root->removeChild($node);
         }
     }
     $out = $this->domdocument->saveXML();
     return $out;
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:35,代码来源:Config.class.php

示例9: render

 public function render()
 {
     $dom = $dom = new \DOMDocument('1.0');
     $header = $dom->createElement('h1', $this->_name);
     $dom->appendChild($header);
     $form = $dom->createElement('form');
     $form->setAttribute('action', $this->_action);
     $form->setAttribute('method', $this->_method);
     $form->setAttribute('id', $this->_id);
     if ($this->_enctype != null) {
         $form->setAttribute('enctype', $this->_enctype);
     }
     $dom->appendChild($form);
     foreach ($this->_fields as $name => $field) {
         if (($field->type == self::FIELD_INPUT_HIDDEN || $field->type == self::FIELD_NOT_RENDER) && $field->error != null) {
             $err = $dom->createElement('div', $field->error);
             $err->setAttribute('class', 'form-field-error');
             $dom->insertBefore($err, $form);
         }
         if (($rendered = $this->createField($name)->render($dom)) != null) {
             $form->appendChild($rendered);
         }
     }
     return $dom->saveHTML();
 }
开发者ID:nazarov-andrey,项目名称:crm,代码行数:25,代码来源:Form.php

示例10: addSortableScriptOnGrid

 /**
  * Appends the "sortable" js code to the bottom of ajax-Request for the category-products loaded after
  * changing sort order.
  *
  * @param Varien_Event_Observer $observer
  */
 public function addSortableScriptOnGrid(Varien_Event_Observer $observer)
 {
     $_block = $observer->getBlock();
     $_type = $_block->getType();
     if (Mage::helper('ffuenf_categoryproductsortbackend')->isExtensionActive() && $_type == 'adminhtml/catalog_category_tab_product') {
         $content = $observer->getTransport()->getHtml();
         $dom = new DOMDocument('1.0', 'utf-8');
         $doc = new DOMDocument('1.0', 'utf-8');
         $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'));
         foreach ($dom->getElementsByTagName('select') as $element) {
             if ($element->getAttribute('name') == 'limit') {
                 $option = $dom->createElement('option');
                 $option->appendChild($dom->createTextNode('All'));
                 $option->setAttribute('value', 0);
                 $option = $element->appendChild($option);
             }
         }
         $additionalHtml = $this->appendScript($content);
         $additionalDoc = new DOMDocument();
         $additionalDoc->loadHTML($additionalHtml);
         $additionalDocScript = $additionalDoc->getElementsByTagName('script')->item(0);
         $body = $dom->getElementsByTagName('body')->item(0);
         foreach ($body->childNodes as $child) {
             $doc->appendChild($doc->importNode($child, true));
         }
         $doc->appendChild($doc->importNode($additionalDocScript, true));
         $content = $doc->saveHTML();
         $observer->getTransport()->setHtml($content);
     }
 }
开发者ID:WestAgency,项目名称:Ffuenf_CategoryProductSortBackend,代码行数:36,代码来源:Observer.php

示例11: createUrlSet

 private function createUrlSet()
 {
     $this->dom = new \DOMDocument('1.0', 'UTF-8');
     $this->urlset = $this->dom->createElement("urlset");
     $this->urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     $this->dom->appendChild($this->urlset);
 }
开发者ID:webremote,项目名称:Sitemap-Craft-Plugin,代码行数:7,代码来源:Sitemap_RenderController.php

示例12: serialize

 /**
  * @param ModelInterface $model
  *
  * @return \DOMDocument
  */
 public function serialize(ModelInterface $model)
 {
     $this->dom = new \DOMDocument('1.0');
     $this->dom->formatOutput = true;
     $element = $this->visitModel($model);
     $this->dom->appendChild($element);
     return $this->dom;
 }
开发者ID:moovly,项目名称:recurly,代码行数:13,代码来源:SerializeVisitor.php

示例13: initialize

 /**
  * Initializes this exporter.
  *
  * @return void
  */
 public function initialize()
 {
     $this->xml = new \DOMDocument('1.0', 'utf-8');
     $this->xml->formatOutput = true;
     $document_element = new \DOMElement('project');
     $this->xml->appendChild($document_element);
     $document_element->setAttribute('version', \phpDocumentor\Application::VERSION);
     $document_element->setAttribute('title', $this->parser->getTitle());
 }
开发者ID:nosenaoki,项目名称:phpDocumentor2,代码行数:14,代码来源:Xml.php

示例14: __construct

 /**
  * Constructor.
  *
  * @param mixed $out
  * @param bool  $reportUselessTests
  */
 public function __construct($out = null, $reportUselessTests = false)
 {
     $this->document = new DOMDocument('1.0', 'UTF-8');
     $this->document->formatOutput = true;
     $this->root = $this->document->createElement('testsuites');
     $this->document->appendChild($this->root);
     parent::__construct($out);
     $this->reportUselessTests = $reportUselessTests;
 }
开发者ID:sebastianbergmann,项目名称:phpunit,代码行数:15,代码来源:JUnit.php

示例15: dumpSchema

 /**
  * Dumps a single Schema model into an XML formatted version.
  *
  * @param  Schema  $schema                The schema object
  * @param  boolean $doFinalInitialization Whether or not to validate the schema
  * @return string
  */
 public function dumpSchema(Schema $schema, $doFinalInitialization = true)
 {
     $rootNode = $this->document->createElement('app-data');
     $this->document->appendChild($rootNode);
     foreach ($schema->getDatabases($doFinalInitialization) as $database) {
         $this->appendDatabaseNode($database, $rootNode);
     }
     return trim($this->document->saveXML());
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:16,代码来源:XmlDumper.php


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