本文整理汇总了PHP中DOMDocument::createElementNS方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::createElementNS方法的具体用法?PHP DOMDocument::createElementNS怎么用?PHP DOMDocument::createElementNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::createElementNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
/**
* (non-PHPdoc)
* @see lib/Faett/Channel/Serializer/Interfaces/Faett_Channel_Serializer_Interfaces_Serializer#serialize()
*/
public function serialize()
{
try {
// initialize a new DOM document
$doc = new DOMDocument('1.0', 'UTF-8');
// create new namespaced root element
$a = $doc->createElementNS($this->_namespace, 'a');
// add the schema to the root element
$a->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://pear.php.net/dtd/rest.allcategories http://pear.php.net/dtd/rest.allcategories.xsd');
// create an element for the channel's name
$ch = $doc->createElement('ch');
$ch->nodeValue = Mage::helper('channel')->getChannelName();
// append the element with the channel's name to the root element
$a->appendChild($ch);
// load the product's attributes
$attributes = $this->_category->getSelectOptions();
// iterate over the channel's categories
foreach ($attributes as $attribute) {
$c = $doc->createElement('c');
$c->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '/channel/index/c/' . $attribute . '/info.xml');
$c->nodeValue = $attribute;
// append the XLink to the root element
$a->appendChild($c);
}
// append the root element to the DOM tree
$doc->appendChild($a);
// return the XML document
return $doc->saveXML();
} catch (Exception $e) {
return $e->getMessage();
}
}
示例2: get
static function get($jid, $start = false, $end = false, $limit = false)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$query = $dom->createElementNS('urn:xmpp:mam:0', 'query');
$x = $dom->createElementNS('jabber:x:data', 'x');
$query->appendChild($x);
$field_type = $dom->createElement('field');
$field_type->setAttribute('var', 'FORM_TYPE');
$field_type->appendChild($dom->createElement('value', 'urn:xmpp:mam:0'));
$x->appendChild($field_type);
$field_with = $dom->createElement('field');
$field_with->setAttribute('var', 'with');
$field_with->appendChild($dom->createElement('value', $jid));
$x->appendChild($field_with);
if ($start) {
$field_start = $dom->createElement('field');
$field_start->setAttribute('var', 'start');
$field_start->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $start + 1)));
$x->appendChild($field_start);
}
if ($end) {
$field_end = $dom->createElement('field');
$field_end->setAttribute('var', 'end');
$field_end->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $end + 1)));
$x->appendChild($field_end);
}
if ($limit) {
$field_limit = $dom->createElement('field');
$field_limit->setAttribute('var', 'limit');
$field_limit->appendChild($dom->createElement($limit));
$x->appendChild($field_limit);
}
$xml = \Moxl\API::iqWrapper($query, null, 'set');
\Moxl\API::request($xml);
}
示例3: getDOM
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
{
if (is_null($doc)) {
$doc = new DOMDocument('1.0', 'utf-8');
}
if ($this->_rootNamespaceURI != null) {
$element = $doc->createElementNS($this->_rootNamespaceURI, $this->_rootElement);
} elseif ($this->_rootNamespace !== null) {
if (strpos($this->_rootElement, ':') === false) {
$elementName = $this->_rootNamespace . ':' . $this->_rootElement;
} else {
$elementName = $this->_rootElement;
}
$element = $doc->createElementNS($this->lookupNamespace($this->_rootNamespace), $elementName);
} else {
$element = $doc->createElement($this->_rootElement);
}
if ($this->_text != null) {
$element->appendChild($element->ownerDocument->createTextNode($this->_text));
}
foreach ($this->_extensionElements as $extensionElement) {
$element->appendChild($extensionElement->getDOM($element->ownerDocument));
}
foreach ($this->_extensionAttributes as $attribute) {
$element->setAttribute($attribute['name'], $attribute['value']);
}
return $element;
}
示例4: set
static function set($data)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');
$publish = $dom->createElement('publish');
$publish->setAttribute('node', 'urn:xmpp:vcard4');
$pubsub->appendChild($publish);
$item = $dom->createElement('item');
$item->setAttribute('id', 'current');
$publish->appendChild($item);
$vcard = $dom->createElementNS('urn:ietf:params:xml:ns:vcard-4.0', 'vcard');
$item->appendChild($vcard);
$fn = $dom->createElement('fn');
$fn->appendChild($dom->createElement('text', $data->fn));
$vcard->appendChild($fn);
$nickname = $dom->createElement('nickname');
$nickname->appendChild($dom->createElement('text', $data->name));
$vcard->appendChild($nickname);
$bday = $dom->createElement('bday');
$bday->appendChild($dom->createElement('date', $data->date));
$vcard->appendChild($bday);
$url = $dom->createElement('url');
$url->appendChild($dom->createElement('uri', $data->url));
$vcard->appendChild($url);
$note = $dom->createElement('note');
$note->appendChild($dom->createElement('text', $data->description));
$vcard->appendChild($note);
$gender = $dom->createElement('gender');
$sex = $dom->createElement('sex');
$gender->appendChild($sex);
$sex->appendChild($dom->createElement('text', $data->gender));
$vcard->appendChild($gender);
$marital = $dom->createElement('marital');
$status = $dom->createElement('status');
$marital->appendChild($status);
$status->appendChild($dom->createElement('text', $data->marital));
$vcard->appendChild($marital);
$impp = $dom->createElement('impp');
$impp->appendChild($dom->createElement('uri', 'xmpp:' . $data->jid));
if ($data->twitter) {
$impp->appendChild($dom->createElement('uri', 'twitter:' . $data->twitter));
}
if ($data->yahoo) {
$impp->appendChild($dom->createElement('uri', 'ymsgr:' . $data->yahoo));
}
if ($data->skype) {
$impp->appendChild($dom->createElement('uri', 'skype:' . $data->skype));
}
$vcard->appendChild($impp);
$email = $dom->createElement('email');
$email->appendChild($dom->createElement('text', $data->email));
$vcard->appendChild($email);
$adr = $dom->createElement('adr');
$adr->appendChild($dom->createElement('locality', $data->adrlocality));
$adr->appendChild($dom->createElement('code', $data->adrpostalcode));
$adr->appendChild($dom->createElement('country', $data->adrcountry));
$vcard->appendChild($adr);
$xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
\Moxl\API::request($xml);
}
示例5: maker
static function maker($to, $content = false, $html = false, $type = 'chat', $chatstates = false, $receipts = false)
{
$session = \Sessionx::start();
$dom = new \DOMDocument('1.0', 'UTF-8');
$root = $dom->createElementNS('jabber:client', 'message');
$dom->appendChild($root);
$root->setAttribute('to', str_replace(' ', '\\40', $to));
$root->setAttribute('id', $session->id);
$root->setAttribute('type', $type);
if ($content != false) {
$body = $dom->createElement('body', $content);
$root->appendChild($body);
}
if ($html != false) {
$xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html');
$body = $dom->createElement('http://www.w3.org/1999/xhtml', 'body', $html);
$xhtml->appendChild($body);
$root->appendChild($xhtml);
}
if ($chatstates != false) {
$chatstate = $dom->createElementNS('http://jabber.org/protocol/chatstates', $chatstates);
$root->appendChild($chatstate);
}
if ($receipts != false) {
if ($receipts == 'request') {
$request = $dom->createElement('request');
} else {
$request = $dom->createElement('received');
$request->setAttribute('id', $receipts);
}
$request->setAttribute('xmlns', 'urn:xmpp:receipts');
$root->appendChild($request);
}
\Moxl\API::request($dom->saveXML($dom->documentElement));
}
示例6: save
/**
* Creates a You Tube Playlist.
*
* @param array $data See Model::save()
* @param boolean $validate See Model::save()
* @param array $fieldList See Model::save()
* @return boolean
*/
public function save($data = null, $validate = true, $fieldList = array())
{
// Create the XML payload
$doc = new DOMDocument('1.0', 'utf-8');
$entry = $doc->createElementNS('http://www.w3.org/2005/Atom', 'entry');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:yt', 'http://gdata.youTube.com/schemas/2007');
$doc->appendChild($entry);
if (isset($data[$this->alias]['title'])) {
$title = $doc->createElement('title', $data[$this->alias]['title']);
$title->setAttribute('type', 'text');
}
$entry->appendChild($title);
if (isset($data[$this->alias]['summary'])) {
$summary = $doc->createElement('summary', $data[$this->alias]['summary']);
}
$entry->appendChild($summary);
if (!empty($data[$this->alias]['private'])) {
$private = $doc->createElementNS('http://gdata.youtube.com/schemas/2007', 'yt:private');
$entry->appendChild($private);
}
// Add the content type in so OAuth won't use the body in the signature
$this->request = array('uri' => array('path' => 'feeds/api/users/default/playlists'), 'header' => array('Content-Type' => 'application/atom+xml'), 'auth' => true, 'body' => $doc->saveXML());
$result = parent::save($data, $validate, $fieldList);
if ($result) {
$this->setInsertID($this->response['entry']['playlistId']);
}
return $result;
}
示例7: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$file = $input->getArgument('file');
if (!preg_match("'^/|(?:[^:\\\\/]+://)|(?:[a-z]:[\\\\/])'i", $file)) {
$file = $this->directory . '/resource/' . $file . '.html.xml';
}
$file = Filesystem::normalizePath($file);
$questionHelper = $this->getHelper('question');
$question = new ConfirmationQuestion(sprintf('Create view <info>%s</info>? [n] ', $file), false);
if (!$questionHelper->ask($input, $output, $question)) {
return;
}
$xml = new \DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$root = $xml->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:composition'));
$root->appendChild($xml->createAttribute('extends'));
$root->appendChild($xml->createAttribute('xmlns'))->appendChild($xml->createTextNode(ExpressViewParser::NS_XHTML));
$root->appendChild($xml->createTextNode("\n\n "));
$block = $root->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:block'));
$block->appendChild($xml->createAttribute('name'))->appendChild($xml->createTextNode('main'));
$block->appendChild($xml->createTextNode("\n TODO: Create composition contents...\n "));
$root->appendChild($xml->createTextNode("\n\n"));
Filesystem::writeFile($file, $xml->saveXML());
$output->writeln('');
$output->writeln(sprintf('CREATED: <info>%s</info>', $file));
}
示例8: serializePriv
/**
* Serializes one privilege
*
* @param DOMDocument $doc
* @param DOMElement $node
* @param string $privName
* @return void
*/
protected function serializePriv($doc, $node, $privName)
{
$xp = $doc->createElementNS('DAV:', 'd:privilege');
$node->appendChild($xp);
$privParts = null;
preg_match('/^{([^}]*)}(.*)$/', $privName, $privParts);
$xp->appendChild($doc->createElementNS($privParts[1], 'd:' . $privParts[2]));
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:16,代码来源:owncloud_3rdparty_Sabre_DAVACL_Property_CurrentUserPrivilegeSet.php
示例9: getTotals
public function getTotals()
{
$totalsContainer = $this->getContextNode()->firstChild;
if (!$totalsContainer) {
$totalsContainer = $this->getContextNode()->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'totals'));
}
return new PHP_CodeCoverage_Report_XML_Totals($totalsContainer);
}
示例10: getLineCoverage
public function getLineCoverage($line)
{
$coverage = $this->contextNode->getElementsByTagNameNS('http://schema.phpunit.de/coverage/1.0', 'coverage')->item(0);
if (!$coverage) {
$coverage = $this->contextNode->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'coverage'));
}
$lineNode = $coverage->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'line'));
return new PHP_CodeCoverage_Report_XML_File_Coverage($lineNode, $line);
}
示例11: get
static function get($xmlns)
{
$dom = new \DOMDocument('1.0', 'utf-8');
$query = $dom->createElementNS('jabber:iq:private', 'query');
$data = $dom->createElementNS($xmlns, 'data');
$query->appendchild($data);
$xml = \Moxl\API::iqWrapper($query, false, 'get');
\Moxl\API::request($xml);
}
示例12: buildRss1
/**
* Return DOM object contains RSS 1.0 fomat feed data.
*
* @param boolean $format_output
* @return object
*/
protected function buildRss1($format_output = false)
{
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = $format_output;
$ns = array('xml' => 'http://www.w3.org/XML/1998/namespace', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rss' => 'http://purl.org/rss/1.0/', 'dc' => 'http://purl.org/dc/elements/1.1/', 'content' => 'http://purl.org/rss/1.0/modules/content/');
$root = $doc->appendChild($doc->createElementNS($ns['rdf'], 'rdf:RDF'));
if (!empty($this->channel->language)) {
$root->setAttributeNS($ns['xml'], 'xml:lang', $this->channel->language);
}
$channel_element = $root->appendChild($doc->createElementNS($ns['rss'], 'channel'));
$channel_element->setAttributeNS($ns['rdf'], 'rdf:about', $this->channel->link);
$channel_element->appendChild($doc->createElementNS($ns['rss'], 'title', $this->channel->title));
$channel_element->appendChild($doc->createElementNS($ns['rss'], 'link', $this->channel->link));
$channel_element->appendChild($doc->createElementNS($ns['rss'], 'description', $this->channel->description));
$channel_element->appendChild($doc->createElementNS($ns['dc'], 'dc:date', date(DATE_W3C, time())));
if (!empty($this->channel->language)) {
$channel_element->appendChild($doc->createElementNS($ns['dc'], 'dc:language', $this->channel->language));
}
if ($this->channel->image and !empty($this->channel->image->url)) {
$image = $channel_element->appendChild($doc->createElementNS($ns['rss'], 'image'));
$image->setAttributeNS($ns['rdf'], 'rdf:resource', $this->channel->image->url);
$image_element = $root->appendChild($doc->createElementNS($ns['rss'], 'image'));
$image_element->setAttributeNS($ns['rdf'], 'rdf:about', $this->channel->image->url);
$image_element->appendChild($doc->createElementNS($ns['rss'], 'url', $this->channel->image->url));
$image_element->appendChild($doc->createElementNS($ns['rss'], 'title', !empty($this->channel->image->title) ? $this->channel->image->title : $this->channel->title));
$image_element->appendChild($doc->createElementNS($ns['rss'], 'link', !empty($this->channel->image->link) ? $this->image->channel->link : $this->channel->link));
}
$items_element = $channel_element->appendChild($doc->createElementNS($ns['rss'], 'items'));
$rdf_seq_element = $items_element->appendChild($doc->createElementNS($ns['rdf'], 'rdf:Seq'));
foreach ($this->channel->items as $item) {
$rdf_li = $rdf_seq_element->appendChild($doc->createElementNS($ns['rdf'], 'rdf:li'));
$rdf_li->setAttributeNS($ns['rdf'], 'rdf:resource', $item->guid);
$item_element = $root->appendChild($doc->createElementNS($ns['rss'], 'item'));
$item_element->setAttributeNS($ns['rdf'], 'rdf:about', $item->guid);
$item_element->appendChild($doc->createElementNS($ns['rss'], 'title', $item->title));
$item_element->appendChild($doc->createElementNS($ns['rss'], 'link', $item->link));
if (!empty($item->description)) {
$plaintext = strip_tags($item->description);
if (function_exists('mb_strimwidth')) {
$plaintext = mb_strimwidth($plaintext, 0, 500, '...', 'UTF-8');
}
$description = $item_element->appendChild($doc->createElementNS($ns['rss'], 'description'));
$description->appendChild($doc->createTextNode($plaintext));
$content_encoded = $item_element->appendChild($doc->createElementNS($ns['content'], 'content:encoded'));
$content_encoded->appendChild($doc->createCDATASection($item->description));
}
if (!empty($item->category)) {
$item_element->appendChild($doc->createElementNS($ns['dc'], 'dc:subject', $item->category));
}
if (!empty($item->pubDate)) {
$item_element->appendChild($doc->createElementNS($ns['dc'], 'dc:date', date(DATE_W3C, $item->pubDate)));
}
}
return $doc;
}
示例13: createArticle
function createArticle($aFileName)
{
$articleDoc = new DOMDocument("1.0", "UTF-8");
$articleDoc->appendChild($articleDoc->createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../component/article/view-article.xsl\""));
$articleDoc->appendChild($articleDoc->createProcessingInstruction("setter", "href=\"../component/article/setter-article.php\""));
$articleE = $articleDoc->appendChild($articleDoc->createElementNS("http://formax.cz/ns/article", "article"));
$articleE->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "http://formax.cz/ns/article ../component/article/model-article.xsd");
$articleE->appendChild($articleDoc->createElementNS("http://formax.cz/ns/article", "h", "nový článek"));
$articleE->appendChild($articleDoc->createElementNS("http://formax.cz/ns/article", "p", "nový článek"));
$articleDoc->save($aFileName);
}
示例14: buildXmlChildElementShema
public function buildXmlChildElementShema(\DOMDocument $xml, \DOMElement $sequence, HelperXmlSchemaBuilder $builder)
{
$when = $sequence->appendChild($xml->createElementNS(self::NS_XSD, 'element'));
$when->setAttribute('ref', 'tns:when');
$when->setAttribute('minOccurs', '1');
$when->setAttribute('maxOccurs', 'unbounded');
$otherwise = $sequence->appendChild($xml->createElementNS(self::NS_XSD, 'element'));
$otherwise->setAttribute('ref', 'tns:otherwise');
$otherwise->setAttribute('minOccurs', '0');
$otherwise->setAttribute('maxOccurs', '1');
}
示例15: serialize
public function serialize(DOMDocument $document)
{
$xsd = ckXsdNamespace::get('xsd');
$node = $document->createElementNS($xsd->getUrl(), $xsd->qualify($this->getNodeName()));
$node->setAttribute('name', $this->getName());
$sequence = $document->createElementNS($xsd->getUrl(), $xsd->qualify('sequence'));
foreach ($this->getElements() as $element) {
$sequence->appendChild($element->serialize($document));
}
$node->appendChild($sequence);
return $node;
}