本文整理汇总了PHP中DOMElement::appendChild方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::appendChild方法的具体用法?PHP DOMElement::appendChild怎么用?PHP DOMElement::appendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::appendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addGroup
public function addGroup($title)
{
$element = $this->createElement('group');
$this->db->appendChild($element);
$element->setTitle($title);
return $element;
}
示例2:
function insert_node(DOMDocument &$doc, DOMElement &$field_elem, SimpleXMLElement $details_xml)
{
$travel_res_submitted_fields = dom_import_simplexml($details_xml->travel_res_submitted_fields[0]);
//$travel_res_submitted_fields = $doc->createElement("travel_res_submitted_fields");
$dom_sxe = $doc->importNode($travel_res_submitted_fields, true);
$field_elem->appendChild($dom_sxe);
if ($details_xml->travel_product[0])
{
$travel_res_product = dom_import_simplexml($details_xml->travel_product[0]);
//$travel_res_submitted_fields = $doc->createElement("travel_res_submitted_fields");
$dom_sxe = $doc->importNode($travel_res_product, true);
$field_elem->appendChild($dom_sxe);
}
if ($details_xml->travel_lookups[0])
{
$travel_res_product_lookups = dom_import_simplexml($details_xml->travel_lookups[0]);
//$travel_res_submitted_fields = $doc->createElement("travel_res_submitted_fields");
$dom_sxe_lkp = $doc->importNode($travel_res_product_lookups, true);
$field_elem->appendChild($dom_sxe_lkp);
}
}
示例3: insertDate
/**
* Inserts <meta:creation-date /> and <dc:date/> tags.
*
* Note that OpenOffice.org 3.1.1 is not capable of parsing W3C compliant
* dates with TZ offset correctly {@see
* http://www.openoffice.org/issues/show_bug.cgi?id=107437}. We do not work
* around this issue, since it's too minor.
*
* @param DOMElement $metaSection
*/
protected function insertDate(DOMElement $metaSection)
{
$date = new DateTime();
$dateString = $date->format(DateTime::W3C);
$metaSection->appendChild($metaSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_META, 'meta:creation-date', $dateString));
$metaSection->appendChild($metaSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_DC, 'dc:date', $dateString));
}
示例4: serialize
/**
* serialize
*
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $prop)
{
$doc = $prop->ownerDocument;
if (!$this->supportsLocks) {
return null;
}
$lockEntry1 = $doc->createElementNS('DAV:', 'd:lockentry');
$lockEntry2 = $doc->createElementNS('DAV:', 'd:lockentry');
$prop->appendChild($lockEntry1);
$prop->appendChild($lockEntry2);
$lockScope1 = $doc->createElementNS('DAV:', 'd:lockscope');
$lockScope2 = $doc->createElementNS('DAV:', 'd:lockscope');
$lockType1 = $doc->createElementNS('DAV:', 'd:locktype');
$lockType2 = $doc->createElementNS('DAV:', 'd:locktype');
$lockEntry1->appendChild($lockScope1);
$lockEntry1->appendChild($lockType1);
$lockEntry2->appendChild($lockScope2);
$lockEntry2->appendChild($lockType2);
$lockScope1->appendChild($doc->createElementNS('DAV:', 'd:exclusive'));
$lockScope2->appendChild($doc->createElementNS('DAV:', 'd:shared'));
$lockType1->appendChild($doc->createElementNS('DAV:', 'd:write'));
$lockType2->appendChild($doc->createElementNS('DAV:', 'd:write'));
//$frag->appendXML('<d:lockentry><d:lockscope><d:exclusive /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>');
//$frag->appendXML('<d:lockentry><d:lockscope><d:shared /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>');
}
示例5: __get
/**
* Appends child node
*
* @param $tag
* @return XmlBuilder
*/
public function __get($tag)
{
$node = $this->__dom__->createElement($tag);
$this->__currentNode__->appendChild($node);
$this->__currentNode__ = $node;
return $this;
}
示例6: convert_to_xml
/**
* This function converts an associated array to an XML string.
*
* @access protected
* @static
* @param array $array the associated array to be converted
* @param DOMElement $domElement the XML DOM element
* @param DOMDocument $document the XML DOM document
* @return string a string formatted with XML
*
* @see http://darklaunch.com/2009/05/23/php-xml-encode-using-domdocument-convert-array-to-xml-json-encode
*/
protected static function convert_to_xml($array, $domElement = NULL, $document = NULL)
{
if ($document === NULL) {
$document = new DOMDocument();
$document->formatOutput = TRUE;
static::convert_to_xml($array, $document, $document);
return $document->asXML();
} else {
if (is_array($array)) {
foreach ($array as $node => $value) {
$element = NULL;
if (is_integer($node)) {
$element = $domElement;
} else {
$element = $document->createElement($node);
$domElement->appendChild($element);
}
static::convert_to_xml($value, $element, $document);
}
} else {
if (is_string($array) and preg_match('/^<!CDATA\\[.*\\]\\]>$/', $array)) {
$array = substr($array, 8, strlen($array) - 11);
$element = $document->createCDATASection($array);
$domElement->appendChild($element);
} else {
$element = $document->createTextNode($array);
$domElement->appendChild($element);
}
}
}
}
示例7: createRequest
/**
* Build the document structures based on parameters and arguments. This method
* is also called if you convert ths class instance to string
*/
public function createRequest()
{
if ($this->__documentReady === true) {
return true;
}
foreach ($this->__argumentData as $aName => $aValue) {
$argument = $this->createElement('argument');
$argument->setAttribute('name', $aName);
$argument->appendChild($this->createCDATASection($aValue));
$this->__rootNode->appendChild($argument);
}
$resourceDescriptor = $this->createElement('resourceDescriptor');
foreach ($this->__resourceDescriptors as $rName => $rValue) {
$resourceDescriptor->setAttribute($rName, $rValue);
}
$label = $this->createElement('label', $this->__label == null ? 'null' : $this->__label);
$resourceDescriptor->appendChild($label);
foreach ($this->__parameterData as $pName => $pValue) {
$parameter = $this->createElement('parameter');
$parameter->setAttribute('name', $pName);
$parameter->appendChild($this->createCDATASection($pValue));
$resourceDescriptor->appendChild($parameter);
}
$this->__rootNode->appendChild($resourceDescriptor);
return $this->__documentReady = true;
}
示例8: array2domAttr
/**
* Add dom attributes from array
* @static
* @param \DOMElement|\DOMNode $node
* @param array $array
* @param bool $verbal
*/
public static function array2domAttr(&$node, $array, $verbal = false)
{
if (is_array($array) and !empty($array)) {
foreach ($array as $k => $v) {
if (is_numeric($k) and !is_array($v) and !is_object($v) and ctype_alnum($v)) {
$node->appendChild($node->ownerDocument->createElement(ctype_alpha($v[0]) ? $v : "_{$v}"));
} elseif (is_array($v)) {
if (is_numeric($k)) {
$k = "_{$k}";
}
$newNode = $node->appendChild($node->ownerDocument->createElement($k));
self::array2domAttr($newNode, $v, $verbal);
} elseif (is_object($v)) {
} else {
if ($verbal) {
if (is_null($v)) {
$v = 'null';
} elseif ($v === false) {
$v = 'false';
} elseif ($v === true) {
$v = 'true';
} elseif ($v === 0) {
$v = '0';
}
}
$node->setAttribute(ctype_alpha($k[0]) ? $k : "_{$k}", $v);
}
}
}
}
示例9: addElement
private function addElement(EntryModel $entry, $changeFrequency, $priority)
{
//Check if manually hidden
if ($entry->SiteMapPluginHideFromSiteMap) {
return;
}
//Check if entry has URL, some sections don't
if (!$entry->getUrl()) {
return;
}
$url = $this->dom->createElement('url');
$urlLoc = $this->dom->createElement('loc');
$urlLoc->nodeValue = $entry->getUrl();
$url->appendChild($urlLoc);
$urlModified = $this->dom->createElement('lastmod');
$urlModified->nodeValue = $entry->postDate->w3c();
$url->appendChild($urlModified);
$urlChangeFreq = $this->dom->createElement('changefreq');
$urlChangeFreq->nodeValue = $changeFrequency;
$url->appendChild($urlChangeFreq);
$urlPriority = $this->dom->createElement('priority');
$urlPriority->nodeValue = $priority;
$url->appendChild($urlPriority);
$this->urlset->appendChild($url);
}
示例10: addHeaderElement
/**
* Add new soap header.
*
* @param \DOMElement $node DOMElement to add
* @param boolean $mustUnderstand SOAP header mustUnderstand attribute
* @param string $actor SOAP actor/role
* @param string $soapVersion SOAP version SOAP_1_1|SOAP_1_2
*
* @return void
*/
public function addHeaderElement(\DOMElement $node, $mustUnderstand = null, $actor = null, $soapVersion = SOAP_1_1)
{
$root = $this->domDocument->documentElement;
$namespace = $root->namespaceURI;
$prefix = $root->prefix;
if (null !== $mustUnderstand) {
$node->appendChild(new \DOMAttr($prefix . ':mustUnderstand', (int) $mustUnderstand));
}
if (null !== $actor) {
$attributeName = $soapVersion == SOAP_1_1 ? 'actor' : 'role';
$node->appendChild(new \DOMAttr($prefix . ':' . $attributeName, $actor));
}
$nodeListHeader = $root->getElementsByTagNameNS($namespace, 'Header');
// add header if not there
if ($nodeListHeader->length == 0) {
// new header element
$header = $this->domDocument->createElementNS($namespace, $prefix . ':Header');
// try to add it before body
$nodeListBody = $root->getElementsByTagNameNS($namespace, 'Body');
if ($nodeListBody->length == 0) {
$root->appendChild($header);
} else {
$body = $nodeListBody->item(0);
$header = $body->parentNode->insertBefore($header, $body);
}
$header->appendChild($node);
} else {
$nodeListHeader->item(0)->appendChild($node);
}
}
示例11: setMessageElements
/**
* Sets the message elements for this operation into the wsdl document
* @param DOMElement $wsdl The parent domelement for the messages
* @param DomDocument $dom The dom document to create the messages as children of
*/
public function setMessageElements(DOMElement $wsdl, DOMDocument $dom)
{
$input = $this->inputMessage->getMessageElement($dom);
$output = $this->outputMessage->getMessageElement($dom);
$wsdl->appendChild($input);
$wsdl->appendChild($output);
}
示例12: getHTMLNodeInner
/**
* Get the html node for this element
*
* @param \DOMElement $node
* @param \AppShed\Remote\XML\DOMDocument $xml
* @param \AppShed\Remote\HTML\Settings $settings
*/
protected function getHTMLNodeInner($node, $xml, $settings)
{
if (!empty($this->title)) {
$node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title]));
}
$node->appendChild($inner = $xml->createElement('div', 'textbox-container' . (empty($this->title) ? ' no-title' : '')));
$inner->appendChild($xml->createElement('span', ['class' => 'picked', 'data-value' => $this->value ? $this->type == static::TYPE_DATE ? $this->value->getTimestamp() : $this->value->format('H:i') : null, 'data-placeholder' => $this->placeHolder, 'data-variable' => $this->variableName, 'data-picker-type' => $this->type, 'data-save-value' => $this->save]));
}
示例13: add
/**
* @param Sitemap_URL $object
*/
public function add(Sitemap_URL $object)
{
$url = $object->create();
// Decorate the urlset
$object->root($this->_root);
// Append URL to root element
$this->_root->appendChild($this->_xml->importNode($url, TRUE));
}
示例14: getHTMLNodeInner
/**
* Get the html node for this element
*
* @param \DOMElement $node
* @param \AppShed\Remote\XML\DOMDocument $xml
* @param \AppShed\Remote\HTML\Settings $settings
*/
protected function getHTMLNodeInner($node, $xml, $settings)
{
if ($this->image) {
$node->appendChild($xml->createImgElement($this->image->getUrl(), 'icon', $this->image->getSize()));
}
$node->appendChild($xml->createElement('div', ['class' => 'text', 'text' => $this->title]));
$this->applyLinkToNode($xml, $node, $settings);
}
示例15: getHTMLNodeInner
/**
* Get the html node for this element
*
* @param \DOMElement $node
* @param \AppShed\Remote\XML\DOMDocument $xml
* @param \AppShed\Remote\HTML\Settings $settings
*/
protected function getHTMLNodeInner($node, $xml, $settings)
{
if (!empty($this->title)) {
$node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title]));
}
$node->appendChild($inner = $xml->createElement('div', 'textarea-container' . (empty($this->title) ? ' no-title' : '')));
$inner->appendChild($xml->createElement('textarea', ['class' => 'textarea', 'name' => $this->variableName, 'text' => $this->value, 'data-variable' => $this->variableName, 'data-save-value' => $this->save]));
}