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


PHP DomDocument::appendChild方法代码示例

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


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

示例1: DomDocument

 function props_to_xml()
 {
     # make the source xml
     # make doc and root
     $xml = new DomDocument();
     $root = $xml->createElement('request');
     $root->setAttribute('controller', params('controller'));
     $root->setAttribute('action', params('action'));
     $root = $xml->appendChild($root);
     # unpack the props into xml
     foreach ($this->props as $k => $v) {
         # if it will become xml, do that, otherwise make a dumb tag
         if (is_object($v) && method_exists($v, 'to_xml')) {
             $obj_xml = $v->to_xml(array(), true, true);
             $obj_xml = $xml->importNode($obj_xml->documentElement, true);
             $root->appendChild($obj_xml);
         } else {
             $node = $xml->createElement($k);
             if (strpos($v, '<') !== false || strpos($v, '>') !== false || strpos($v, '&') !== false) {
                 $cdata = $xml->createCDATASection($v);
             } else {
                 $cdata = $xml->createTextNode($v);
             }
             $node->appendChild($cdata);
             $node = $root->appendChild($node);
         }
     }
     return $xml;
 }
开发者ID:brysonian,项目名称:Saint,代码行数:29,代码来源:AbstractView.php

示例2: __construct

 /**
  * Constructor
  * @return unknown_type
  */
 public function __construct()
 {
     $this->_document = new DOMDocument();
     //create structute /xml/content
     $this->_document->appendChild($this->_document->createElement('xml'));
     $this->_contentNode = $this->_document->createElement('content');
     $this->_document->documentElement->appendChild($this->_contentNode);
 }
开发者ID:kandy,项目名称:system,代码行数:12,代码来源:PartialRenderer.php

示例3: write

 /**
  * @see Drest\Writer\Writer::write()
  */
 public function write(ResultSet $data)
 {
     $this->xml = new \DomDocument('1.0', 'UTF-8');
     $this->xml->formatOutput = true;
     $dataArray = $data->toArray();
     if (key($dataArray) === 0) {
         // If there is no key, we need to use a default
         $this->xml->appendChild($this->convertArrayToXml('result', $dataArray));
     } else {
         $this->xml->appendChild($this->convertArrayToXml(key($dataArray), $dataArray[key($dataArray)]));
     }
     $this->data = $this->xml->saveXML();
 }
开发者ID:leedavis81,项目名称:drest-common,代码行数:16,代码来源:Xml.php

示例4: run

 public function run()
 {
     $apiDocument = $this->document->createElement("api");
     try {
         $apiDocument = $this->execute($apiDocument);
     } catch (ApiException $ex) {
         $exception = $this->document->createElement("error");
         $exception->setAttribute("message", $ex->getMessage());
         $apiDocument->appendChild($exception);
     }
     $this->document->appendChild($apiDocument);
     return $this->document->saveXml();
 }
开发者ID:Austin503,项目名称:waca,代码行数:13,代码来源:ApiActionBase.php

示例5: setUp

 protected function setUp()
 {
     // Setup DOM
     $this->domDocument = new \DOMDocument('1', 'UTF-8');
     $html = $this->domDocument->createElement('html');
     $this->domAnchor = $this->domDocument->createElement('a', 'fake');
     $this->domAnchor->setAttribute('href', 'http://php-spider.org/contact/');
     $this->domDocument->appendChild($html);
     $html->appendChild($this->domAnchor);
     $this->uri = new DiscoveredUri(new Uri($this->domAnchor->getAttribute('href')));
     // Setup Spider\Resource
     $content = $this->domDocument->saveHTML();
     $this->spiderResource = new Resource($this->uri, new Response(200, [], $content));
 }
开发者ID:ggnet,项目名称:php-spider,代码行数:14,代码来源:DiscovererTestCase.php

示例6: createCoursesDom

function createCoursesDom($coursesArr) {
    global $langMyCoursesProf, $langMyCoursesUser;

    $dom = new DomDocument('1.0', 'utf-8');

    if (defined('M_ROOT')) {
        $root0 = $dom->appendChild($dom->createElement(M_ROOT));
        $root = $root0->appendChild($dom->createElement('courses'));
        $retroot = $root0;
    } else {
        $root = $dom->appendChild($dom->createElement('courses'));
        $retroot = $root;
    }

    if (isset($coursesArr) && count($coursesArr) > 0) {

        $k = 0;
        $this_status = 0;

        foreach ($coursesArr as $course) {

            $old_status = $this_status;
            $this_status = $course->status;

            if ($k == 0 || ($old_status != $this_status)) {
                $cg = $root->appendChild($dom->createElement('coursegroup'));
                $gname = ($this_status == 1) ? $langMyCoursesProf : $langMyCoursesUser;
                $cg->appendChild(new DOMAttr('name', $gname));
            }

            $c = $cg->appendChild($dom->createElement('course'));

            $titleStr = ($course->code === $course->public_code) ? $course->title : $course->title . ' - ' . $course->public_code;

            $c->appendChild(new DOMAttr('code', $course->code));
            $c->appendChild(new DOMAttr('title', $titleStr));
            $c->appendChild(new DOMAttr('description', ""));

            //$c->appendChild(new DOMAttr('teacher', $course->titulaires));
            //$c->appendChild(new DOMAttr('visible', $course->visible));
            //$c->appendChild(new DOMAttr('visibleName', getVisibleName($course->visible)));

            $k++;
        }
    }

    $dom->formatOutput = true;
    return array($dom, $retroot);
}
开发者ID:nikosv,项目名称:openeclass,代码行数:49,代码来源:mcourses.php

示例7: create_xml

 private function create_xml($respuesta, $rfc_emisor, $rfc_receptor, $total_factura, $uuid, $web_service, $hora_envio, $hora_recepcion, $md5)
 {
     $doc = new DomDocument('1.0', 'UTF-8');
     $doc->formatOutput = true;
     $root = $doc->createElement('RespuestaSAT');
     $doc->appendChild($root);
     $webService = $doc->createElement('WebService', "{$web_service}");
     $root->appendChild($webService);
     $emisorRfc = $doc->createElement('EmisorRfc', "{$rfc_emisor}");
     $root->appendChild($emisorRfc);
     $receptorRfc = $doc->createElement("ReceptorRFC", "{$rfc_receptor}");
     $root->appendChild($receptorRfc);
     $FechaHoraEnvio = $doc->createElement("FechaHoraEnvio", "{$hora_envio}");
     $root->appendChild($FechaHoraEnvio);
     $FechaHoraRespuesta = $doc->createElement("FechaHoraRespuesta", "{$hora_recepcion}");
     $root->appendChild($FechaHoraRespuesta);
     $TotalFactura = $doc->createElement("TotalFactura", "{$total_factura}");
     $root->appendChild($TotalFactura);
     $UUID = $doc->createElement("UUID", $uuid);
     $root->appendChild($UUID);
     $codigoEstatus = $doc->createElement('CodigoEstatus', $respuesta->ConsultaResult->CodigoEstatus);
     $root->appendChild($codigoEstatus);
     $estado = $doc->createElement('Estado', $respuesta->ConsultaResult->Estado);
     $root->appendChild($estado);
     $acuse = $doc->createElement("AcuseRecibo", "{$md5}");
     $root->appendChild($acuse);
     //        $doc->save('RespuestaSAT.xml');
     //        echo htmlentities($doc->saveXML());
     return $doc;
 }
开发者ID:njmube,项目名称:CSDOCSCFDI,代码行数:30,代码来源:webservice_sat.php

示例8: _toHtml

 public function _toHtml()
 {
     $this->_checkRequired();
     $info = $this->getInfo();
     $certain = $info['certain'];
     $dom = new DomDocument();
     $dom->preserveWhitespace = false;
     $block = $dom->createElement('block');
     $attr = $dom->createAttribute('type');
     $attr->value = $this->getAlias();
     $block->appendChild($attr);
     $dom->appendChild($block);
     $output = simplexml_load_string('<block />');
     foreach ($certain as $method) {
         $block->appendChild($dom->createComment("\n     " . $this->_getDocumentation($method) . "\n  "));
         $dom_action = $dom->createElement('action');
         $block->appendChild($dom_action);
         $dom_attr = $dom->createAttribute('method');
         $dom_attr->value = $method->getName();
         $dom_action->appendChild($dom_attr);
         $this->addParamsToDomActionNodeFromReflectionMethod($dom, $dom_action, $method);
         //$action = $this->addParamsToActionNodeFromReflectionMethod($action, $method);
     }
     $dom->formatOutput = true;
     return $this->_extraXmlFormatting($dom->saveXml());
 }
开发者ID:itmyprofession,项目名称:Pulsestorm,代码行数:26,代码来源:Action.php

示例9: prepareData

 protected function prepareData()
 {
     $v4b43b0aee35624cd95b910189b3dc231 = $this->reader;
     $v9a09b4dfda82e3e665e31092d1c3ec8d = new DomDocument();
     $v5118e2d6cb8d101c16049b9cf18de377 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement("yml_catalog");
     $v9a09b4dfda82e3e665e31092d1c3ec8d->appendChild($v5118e2d6cb8d101c16049b9cf18de377);
     $v63a9f0ea7bb98050796b649e85481845 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement("shop");
     $v5118e2d6cb8d101c16049b9cf18de377->appendChild($v63a9f0ea7bb98050796b649e85481845);
     $v7a86c157ee9713c34fbd7a1ee40f0c5a = $this->offset;
     while ($v4b43b0aee35624cd95b910189b3dc231->read() && $v4b43b0aee35624cd95b910189b3dc231->name != 'categories') {
         if ($v4b43b0aee35624cd95b910189b3dc231->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         if ($v4b43b0aee35624cd95b910189b3dc231->name == 'yml_catalog' || $v4b43b0aee35624cd95b910189b3dc231->name == 'shop') {
             continue;
         }
         $v8e2dcfd7e7e24b1ca76c1193f645902b = $v4b43b0aee35624cd95b910189b3dc231->expand();
         $v63a9f0ea7bb98050796b649e85481845->appendChild($v8e2dcfd7e7e24b1ca76c1193f645902b);
     }
     $v4757fe07fd492a8be0ea6a760d683d6e = 0;
     while ($v4b43b0aee35624cd95b910189b3dc231->read() && $v4757fe07fd492a8be0ea6a760d683d6e < $v7a86c157ee9713c34fbd7a1ee40f0c5a) {
         if ($v4b43b0aee35624cd95b910189b3dc231->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         if ($v4b43b0aee35624cd95b910189b3dc231->name == 'category' || $v4b43b0aee35624cd95b910189b3dc231->name == 'offer') {
             $v4757fe07fd492a8be0ea6a760d683d6e++;
         }
     }
     $this->offset += $v4757fe07fd492a8be0ea6a760d683d6e;
     $this->doc = $v9a09b4dfda82e3e665e31092d1c3ec8d;
 }
开发者ID:BGCX261,项目名称:zimmerli-svn-to-git,代码行数:31,代码来源:ymlSplitter.php

示例10: 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

示例11: errorHandler

function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
    # capture some additional information
    $agent = $_SERVER['HTTP_USER_AGENT'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $referrer = $_SERVER['HTTP_REFERER'];
    $dt = date("Y-m-d H:i:s (T)");
    # grab email info if available
    global $err_email, $err_user_name;
    # use this to email problem to maintainer if maintainer info is set
    if (isset($err_user_name) && isset($err_email)) {
    }
    # Write error message to user with less details
    $xmldoc = new DomDocument('1.0');
    $xmldoc->formatOutput = true;
    # Set root
    $root = $xmldoc->createElement("error_handler");
    $root = $xmldoc->appendChild($root);
    # Set child
    $occ = $xmldoc->createElement("error");
    $occ = $root->appendChild($occ);
    # Write error message
    $child = $xmldoc->createElement("error_message");
    $child = $occ->appendChild($child);
    $fvalue = $xmldoc->createTextNode("Your request has returned an error: " . $errstr);
    $fvalue = $child->appendChild($fvalue);
    $xml_string = $xmldoc->saveXML();
    echo $xml_string;
    # exit request
    exit;
}
开发者ID:oliviervanre,项目名称:GeolocOptinAdhoc,代码行数:31,代码来源:error.inc.php

示例12: 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

示例13: toXml

 /**
  * Convert a tree array (with depth) into a hierarchical XML string.
  *
  * @param $nodes|array   Array with depth value.
  *
  * @return string
  */
 public function toXml(array $nodes)
 {
     $xml = new DomDocument('1.0');
     $xml->preserveWhiteSpace = false;
     $root = $xml->createElement('root');
     $xml->appendChild($root);
     $depth = 0;
     $currentChildren = array();
     foreach ($nodes as $node) {
         $element = $xml->createElement('element');
         $element->setAttribute('id', $node['id']);
         $element->setAttribute('name', $node['name']);
         $element->setAttribute('lft', $node['lft']);
         $element->setAttribute('rgt', $node['rgt']);
         $children = $xml->createElement('children');
         $element->appendChild($children);
         if ($node['depth'] == 0) {
             // Handle root
             $root->appendChild($element);
             $currentChildren[0] = $children;
         } elseif ($node['depth'] > $depth) {
             // is a new sub level
             $currentChildren[$depth]->appendChild($element);
             $currentChildren[$node['depth']] = $children;
         } elseif ($node['depth'] == $depth || $node['depth'] < $depth) {
             // is at the same level
             $currentChildren[$node['depth'] - 1]->appendChild($element);
         }
         $depth = $node['depth'];
     }
     return $xml->saveXML();
 }
开发者ID:visualweber,项目名称:appzf1,代码行数:39,代码来源:Output.php

示例14: makeXml

function makeXml($dbObject)
{
    header("Content-Type: application/xml");
    $doc = new DomDocument('1.0', 'UTF-8');
    $uid = $doc->createElement('uid');
    for ($i = 0; $i < $dbObject->rowCount(); $i++) {
        $result = $dbObject->fetch();
        if ($i === 0) {
            $id = $doc->createAttribute('id');
            $id->value = $result['usernum'];
            $uid->appendChild($id);
            $doc->appendChild($uid);
        }
        $prefix = array($result['num'], $result['in_out'], $result['type'], $result['amount'], $result['time'], $result['detail']);
        list($tnum, $inout, $type, $amount, $time, $detail) = $prefix;
        $trade_num = $doc->createElement('tnum');
        $tr_att = $doc->createAttribute('nu');
        $tr_att->value = $tnum;
        $trade_num->appendChild($tr_att);
        $trade_num->appendChild($doc->createElement('inout', $inout));
        $trade_num->appendChild($doc->createElement('type', $type));
        $trade_num->appendChild($doc->createElement('amount', $amount));
        $trade_num->appendChild($doc->createElement('time', $time));
        $trade_num->appendChild($doc->createElement('detail', $detail));
        $uid->appendChild($trade_num);
    }
    $xml = $doc->saveXML();
    print $xml;
}
开发者ID:kwonyoungjae,项目名称:MoneyBook,代码行数:29,代码来源:calendar.php

示例15: showAction

 public function showAction()
 {
     set_time_limit(600);
     // 10 min
     //		ini_set('output_buffering', '4096');
     $nodeid = $this->getRequest()->getParam('id', -1);
     $this->_zip = new Uman_ZipStream("pack_{$nodeid}.pkg");
     $xml = new DomDocument('1.0', 'utf-8');
     $root = $xml->appendChild(new DOMElement('package'));
     $content = $xml->createElement('content');
     $content = $root->appendChild($content);
     $this->addLevel($this->_db->fetchAll($this->_rootsql, $nodeid), $content, $this->getRequest()->getParam('contentinc', false));
     $packid = $this->_db->nextSequenceId('GEN_UID');
     $this->addInfo($nodeid, $root, $packid);
     $this->addTypes($root);
     $this->_zip->add_file('info.xml', $xml->saveXML());
     $this->_zip->finish();
     $AdminDbModel = new Admin_Model_Admin();
     $AdminDbModel->exportPackage($nodeid, $packid);
     /*		header("Content-type: application/x-zip");
     		header("Content-Disposition: attachment; filename=test.zip");
     				
     		$zip = new ZipArchive();
     		if ($zip->open('php://output', ZIPARCHIVE::CREATE)!==TRUE) { // Пока не работает запись в поток
         	echo "cannot open \n";
         	exit;
     		}
     		$zip->addFromString('test.txt', '11111111111');
     		$zip->close();	
     */
     exit;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:32,代码来源:ExportController.php


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