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


PHP DOMDocument::createAttributeNS方法代码示例

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


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

示例1: __construct

 public function __construct(KalturaYouTubeDistributionProfile $distributionProfile)
 {
     $this->_doc = new DOMDocument();
     $this->_doc->formatOutput = true;
     $this->_doc->appendChild($this->_doc->createElement('feed'));
     $this->_doc->createAttributeNS('http://www.youtube.com/schemas/cms/2.0', 'xmlns');
     $this->_xpath = new DOMXPath($this->_doc);
     $timestampName = date('Ymd-His') . '_' . time();
     $this->_directoryName = '/' . $timestampName;
     if ($distributionProfile->sftpBaseDir) {
         $this->_directoryName = '/' . trim($distributionProfile->sftpBaseDir, '/') . $this->_directoryName;
     }
     $this->_metadataTempFileName = 'youtube_xml20_' . $timestampName . '.xml';
 }
开发者ID:dozernz,项目名称:server,代码行数:14,代码来源:YouTubeDistributionRightsFeedHelper.php

示例2: createSitemap

 public function createSitemap()
 {
     $where = "published = 1 and menutype = 'mainmenu' and access IN (1)";
     $result = $this->db->select($this->table_prefix . "menu", "*", "{$where}", 'std');
     $dom = new DOMDocument('1.0');
     $dom->formatOutput = true;
     $root = $dom->createElement('urlset');
     $root = $dom->appendChild($root);
     $ns = $dom->createAttributeNS("http://www.sitemaps.org/schemas/sitemap/0.9", "xmlns");
     foreach ($result["value"] as $row) {
         $link_arr = parse_url($row['link']);
         if (isset($link_arr['query'])) {
             parse_str(html_entity_decode($link_arr['query']), $link_vars);
             $option = HELPER::getValue($link_vars, 'option', '');
             $view = HELPER::getValue($link_vars, 'view', '');
             $layout = HELPER::getValue($link_vars, 'layout', '');
             if ($option == "com_virtuemart" && $view == "category") {
                 $id = HELPER::getValue($link_vars, 'virtuemart_category_id', 0);
             } elseif ($option == "com_fabrik" && $view == "form") {
                 $id = HELPER::getValue($link_vars, 'formid', 0);
             } else {
                 $id = HELPER::getValue($link_vars, 'id', 0);
             }
             $url = $dom->createElement('url');
             $url = $root->appendChild($url);
             $this->setMenuUrl($view, $row, $option, $id, $dom, $root, $url);
         }
     }
     $str = $dom->saveXML();
     echo "Создана карта сайта sitemap.xml, размер " . $dom->save($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $this->SITEMAP_FILE_NAME) . " байт.";
 }
开发者ID:romuland,项目名称:khparts,代码行数:31,代码来源:sitemap.php

示例3: create_attribute_ns

 /**
  *
  * Create new attribute
  * @param string $namespace
  * @param string $name
  * @param string $value
  * @return DOMAttr
  */
 public function create_attribute_ns($namespace, $name, $value = null)
 {
     $result = $this->doc->createAttributeNS($namespace, $name);
     if (!is_null($value)) {
         $result->nodeValue = $value;
     }
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:xmlbase.php

示例4: createAttributeNode

 /**
  * @param PropertyMetadata $metadata
  * @param $attributeName
  *
  * @return \DOMAttr
  */
 private function createAttributeNode(PropertyMetadata $metadata, $attributeName)
 {
     if ($namespace = (string) $metadata->xmlNamespace) {
         $prefix = $this->lookupPrefix($namespace);
         $node = $this->document->createAttributeNS($namespace, $prefix . ':' . $attributeName);
     } else {
         $node = $this->document->createAttribute($attributeName);
     }
     return $node;
 }
开发者ID:alekitto,项目名称:serializer,代码行数:16,代码来源:XmlSerializationVisitor.php

示例5: getNsCode

 public function getNsCode($longNs, $rt = false)
 {
     // if namespace exists - just use its name
     // otherwise add it as nsatrribute to root and use its name
     if (!is_array($this->namespaces)) {
         $this->namespaces = array();
     }
     if (array_key_exists($longNs, $this->namespaces)) {
         return $this->namespaces[$longNs];
     } else {
         $this->namespaces[$longNs] = 'ns' . $this->lastNsKey;
         //$this->logger->debug($this->namespaces[$longNs]);
         if ($rt === false) {
             $nsAttr = $this->dom->createAttributeNS($longNs, $this->namespaces[$longNs] . ":" . $this->rootTagName);
         }
         $this->lastNsKey++;
         return $this->namespaces[$longNs];
     }
 }
开发者ID:irfan-blackhawk,项目名称:XSD-to-PHP,代码行数:19,代码来源:Common.php

示例6: WS_get

/**
 * Handles the GET request
 */
function WS_get()
{
    global $_CONF, $WS_PLUGIN, $WS_INTROSPECTION, $WS_VERBOSE, $_PLUGINS;
    if ($WS_VERBOSE) {
        COM_errorLog("WS: GET request received");
    }
    WS_dissectURI($args);
    if ($WS_INTROSPECTION) {
        header('Content-type: application/atomsvc+xml; charset=UTF-8');
        $atom_uri = $_CONF['site_url'] . '/webservices/atom/';
        /* Determine which plugins have webservices enabled */
        $_ws_plugins = array();
        /* Handle the story 'plugin' separately */
        if (PLG_wsEnabled('story')) {
            $_ws_plugins[] = 'story';
        }
        if (is_array($_PLUGINS)) {
            foreach ($_PLUGINS as $pi) {
                if (PLG_wsEnabled($pi)) {
                    $_ws_plugins[] = $pi;
                }
            }
        }
        /* It might be simpler to do this part directly :-/ */
        $atom_doc = new DOMDocument('1.0', 'utf-8');
        $root_elem = $atom_doc->createElementNS(WS_APP_NS, 'app:service');
        $atom_doc->appendChild($root_elem);
        $atom_doc->createAttributeNS(WS_ATOM_NS, 'atom:service');
        $atom_doc->createAttributeNS(WS_EXTN_NS, 'gl:service');
        $workspace = $atom_doc->createElement('app:workspace');
        $root_elem->appendChild($workspace);
        $title = $atom_doc->createElement('atom:title', $_CONF['site_name']);
        $workspace->appendChild($title);
        foreach ($_ws_plugins as $ws_plugin) {
            $atom_uri_for_plugin = $atom_uri . '?plugin=' . $ws_plugin;
            $collection = $atom_doc->createElement('app:collection');
            $collection->setAttribute('href', $atom_uri_for_plugin);
            $workspace->appendChild($collection);
            $title = $atom_doc->createElement('atom:title', $ws_plugin);
            $collection->appendChild($title);
            $entry = $atom_doc->createElement('app:accept', 'application/atom+xml;type=entry');
            $collection->appendChild($entry);
            $categories = $atom_doc->createElement('app:categories');
            $categories->setAttribute('fixed', 'yes');
            $collection->appendChild($categories);
            $topics = array();
            $msg = array();
            $ret = PLG_invokeService($ws_plugin, 'getTopicList', null, $topics, $msg);
            if ($ret == PLG_RET_OK) {
                foreach ($topics as $t) {
                    $topic = $atom_doc->createElement('atom:category');
                    $topic->setAttribute('term', htmlentities($t));
                    $categories->appendChild($topic);
                }
            }
        }
        WS_write($atom_doc->saveXML());
        return;
    }
    // @TODO Store array $args
    // object id has already been stored from the URI
    /* Indicates that the method is being called by the webservice */
    $args['gl_svc'] = true;
    $ret = PLG_invokeService($WS_PLUGIN, 'get', $args, $out, $svc_msg);
    if ($ret == PLG_RET_OK) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
        header('Content-type: application/atom+xml; charset=UTF-8');
        // Output the actual object/objects here
        if (!$svc_msg['gl_feed']) {
            /* This is an entry, not a feed */
            $etag = '';
            if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                $etag = trim($_SERVER['HTTP_IF_NONE_MATCH'], '"');
            }
            if (!empty($etag) && $out['updated'] == $etag) {
                header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
                exit;
            } else {
                header('Etag: "' . $out['updated'] . '"');
            }
            $atom_doc = new DOMDocument('1.0', 'utf-8');
            $entry_elem = $atom_doc->createElementNS(WS_ATOM_NS, 'atom:entry');
            $atom_doc->appendChild($entry_elem);
            $atom_doc->createAttributeNS(WS_APP_NS, 'app:entry');
            $atom_doc->createAttributeNS(WS_EXTN_NS, 'gl:entry');
            WS_arrayToEntryXML($out, $svc_msg['output_fields'], $entry_elem, $atom_doc);
            WS_write($atom_doc->saveXML());
        } else {
            /* Output the feed here */
            $atom_doc = new DOMDocument('1.0', 'utf-8');
            $feed_elem = $atom_doc->createElementNS(WS_ATOM_NS, 'atom:feed');
            $atom_doc->appendChild($feed_elem);
            $atom_doc->createAttributeNS(WS_APP_NS, 'app:feed');
            $atom_doc->createAttributeNS(WS_EXTN_NS, 'gl:feed');
            $feed_id = $atom_doc->createElement('atom:id', $_CONF['site_name']);
            $feed_elem->appendChild($feed_id);
            $feed_title = $atom_doc->createElement('atom:title', $_CONF['site_name']);
//.........这里部分代码省略.........
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:101,代码来源:lib-webservices.php

示例7: buildElement

 /**
  * @param  \DOMDocument $doc
  * @param  array        $element
  * @return \DOMElement
  */
 protected function buildElement(\DOMDocument $doc, array $element)
 {
     list($name, $value, $attributes) = $element;
     if ($namespace = strtok($name, ':') and isset($this->namespaces[$namespace])) {
         $doc->createAttributeNS($this->namespaces[$namespace], $namespace . ':attr');
     }
     if (is_array($value)) {
         $item = $doc->createElement($name);
         foreach ($value as $tag => $child) {
             $item->appendChild($this->buildElement($doc, [$tag, $child, []]));
         }
     } elseif (in_array($name, $this->cdata)) {
         $item = $doc->createElement($name);
         $item->appendChild($doc->createCDATASection($value));
     } else {
         $item = $doc->createElement($name);
         $item->appendChild($doc->createTextNode($value));
     }
     return $this->buildAttributes($item, (array) $attributes);
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:25,代码来源:Feed.php

示例8: createWSDL_TPL

 /**
  * 
  *
  *
  *
  * @return  bool   TRUE if template XMLObject (with format WSDL) was created, FALSE if not.
  */
 private function createWSDL_TPL()
 {
     if (empty($this->nameWSDL)) {
         $this->errorMSG = "WSDL name isn't defined.";
         return false;
     }
     if (empty($this->targetNamespace)) {
         $this->errorMSG = "WSDL targetNamespace isn't defined.";
         return false;
     }
     if (empty($this->soapAddress)) {
         $this->errorMSG = "WSDL soapAddress isn't defined.";
         return false;
     }
     // Create Document XML with namespace
     // xsd  for namespace (schema),  http://www.w3.org/2001/XMLSchema
     // soap for namespace (soap),    http://schemas.xmlsoap.org/wsdl/soap/
     // elx  for namespace (elastix), ex. http://www.elastix.org/webservices/
     try {
         $doc = new DOMDocument("1.0", "UTF-8");
         $root = $doc->createElementNS($this->ns_wsdl, "{$this->prefix_ns_wsdl}:definitions");
         $doc->appendChild($root);
         $doc->createAttributeNS($this->ns_schema, "{$this->prefix_ns_schema}:schema");
         $doc->createAttributeNS($this->ns_soap, "{$this->prefix_ns_soap}:soap");
         $doc->createAttributeNS($this->targetNamespace, "{$this->prefix_ns_elx}:elastix");
         $attrname = $doc->createAttribute('name');
         //WSDL name Attribute
         $root->appendChild($attrname);
         $valname = $doc->createTextNode($this->nameWSDL);
         $attrname->appendChild($valname);
         $attrtns = $doc->createAttribute('targetNamespace');
         //WSDL tns Attribute
         $root->appendChild($attrtns);
         $valtns = $doc->createTextNode($this->targetNamespace);
         $attrtns->appendChild($valtns);
         $tplWSDL = simplexml_import_dom($doc);
         if (!$tplWSDL) {
             echo "ERROR";
             $this->errorMSG = "Failed loading XML\n";
             foreach (libxml_get_errors() as $error) {
                 $this->errorMSG .= "\t" . $error->message;
             }
             return false;
         }
         //Types
         $objTypes = $tplWSDL->addChild("{$this->prefix_ns_wsdl}:types", null, $this->ns_wsdl);
         $objSchem = $objTypes->addChild("{$this->prefix_ns_schema}:schema", null, $this->ns_schema);
         $objSchem->addAttribute("elementFormDefault", "qualified");
         $objSchem->addAttribute("targetNamespace", $this->targetNamespace);
         $this->node_SchemaTypes = $objSchem;
         //Port Type
         $objPortType = $tplWSDL->addChild("{$this->prefix_ns_wsdl}:portType", null, $this->ns_wsdl);
         $objPortType->addAttribute("name", "{$this->nameWSDL}_SOAPPort");
         $this->node_PortType = $objPortType;
         //Binding
         $objBinding = $tplWSDL->addChild("{$this->prefix_ns_wsdl}:binding", null, $this->ns_wsdl);
         $objBinding->addAttribute("name", "{$this->nameWSDL}_SOAP");
         $objBinding->addAttribute("type", "{$this->prefix_ns_elx}:{$this->nameWSDL}_SOAPPort");
         $objSOAPBin = $objBinding->addChild("{$this->prefix_ns_soap}:binding", null, $this->ns_soap);
         $objSOAPBin->addAttribute("style", "document");
         $objSOAPBin->addAttribute("transport", "http://schemas.xmlsoap.org/soap/http");
         $this->node_Binding = $objBinding;
         //Service
         $objService = $tplWSDL->addChild("{$this->prefix_ns_wsdl}:service", null, $this->ns_wsdl);
         $objService->addAttribute("name", "{$this->nameWSDL}_Service");
         $objPort = $objService->addChild("{$this->prefix_ns_wsdl}:port", null, $this->ns_wsdl);
         $objPort->addAttribute("name", "{$this->nameWSDL}_Port");
         $objPort->addAttribute("binding", "{$this->prefix_ns_elx}:{$this->nameWSDL}_SOAP");
         $objAddress = $objPort->addChild("{$this->prefix_ns_soap}:address", null, $this->ns_soap);
         $objAddress->addAttribute("location", $this->soapAddress);
         $this->node_Service = $objService;
         $this->objWSDL = $tplWSDL;
     } catch (DOMException $ex) {
         $this->errorMSG = "Failed generate WSDL - " . $ex->getMessage();
         return false;
     }
     return true;
 }
开发者ID:lordbasex,项目名称:elastix-gui,代码行数:85,代码来源:WSDLcreator.class.php

示例9: update_attribute_ns

 protected function update_attribute_ns(DOMDocument &$doc, $attrname, $attrnamespace, $attrvalue, DOMElement &$node)
 {
     $busenew = is_object($node) && $node->hasAttributeNS($attrnamespace, $attrname);
     $nResult = null;
     if (!$busenew && is_null($attrvalue)) {
         $node->removeAttributeNS($attrnamespace, $attrname);
     } else {
         $nResult = $busenew ? $node->getAttributeNodeNS($attrnamespace, $attrname) : $doc->createAttributeNS($attrnamespace, $attrname);
         $nResult->nodeValue = $attrvalue;
         if (!$busenew) {
             $node->appendChild($nResult);
         }
     }
     return $nResult;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:cc_version1.php

示例10: load

 /**
  *  Load template data from a DOMDocument, DOMElement, string or file
  *  @name   load
  *  @type   method
  *  @access public
  *  @param  mixed source
  *  @param  ScaffoldTemplate parentTemplate
  *  @param  bool prepare
  *  @return ScaffoldTemplate
  */
 public function load($source, $parentTemplate = null, $prepare = true)
 {
     $this->_enterPhase(self::PHASE_INIT);
     $data = null;
     if ($source instanceof DOMDocument) {
         $data = $source;
         $this->origin = '(DOMDocument) ' . substr($source->saveXML(), 0, 150);
     } else {
         if ($source instanceof DOMElement) {
             $data = new DOMDocument();
             $data->appendChild($data->importNode($source, true));
             $this->origin = '(DOMElement) ' . substr($source->ownerDocument->saveXML($source), 0, 150);
         } else {
             if (is_string($source)) {
                 $data = new DOMDocument();
                 $file = $this->_getFileName($source);
                 $source = $this->_wrapSource($file ? file_get_contents($file) : $source);
                 $data->loadXML($source);
                 $this->origin = $file ? '(file) ' . $file : '(string) ' . substr($source, 0, 150);
             } else {
                 $this->exception('Cannot load template from (' . gettype($source) . ')' . var_export($source, true));
             }
         }
     }
     if ($data instanceof DOMDocument) {
         foreach ($this->_namespace as $namespace => $path) {
             if (!empty($path)) {
                 $data->createAttributeNS($path, $namespace . ':' . get_class($this));
             }
         }
         $this->_content = $data;
         $this->_xpath = new DOMXPath($this->_content);
         if ($prepare) {
             $this->prepare();
         }
     }
     if ($parentTemplate instanceof self) {
         $parentTemplate->addChild($this);
     }
     $this->_enterPhase(self::PHASE_READY);
     return $this;
 }
开发者ID:rspieker,项目名称:konsolidate_scaffold,代码行数:52,代码来源:template.class.php

示例11: DOMElement

echo 'Attribute num exists?: ' . ($node->hasAttribute('num') ? 'Yes' : 'No') . "\n";
echo "Language: " . $node->getAttribute('language') . "\n";
$lang = $node->getAttributeNode('language');
$lang->nodeValue = 'en-US';
$node->setAttributeNode($lang);
echo "Language: " . $node->getAttribute('language') . "\n";
$node->removeAttributeNode($lang);
echo "Language: " . $node->getAttribute('language') . "\n";
echo "\n-- xml:lang --\n";
$node->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', 'en');
echo "Language: " . $node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang') . "\n";
echo 'Attribute xml:lang exists?: ' . ($node->hasAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang') ? 'Yes' : 'No') . "\n";
$node->removeAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang');
echo "Language: " . $node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang') . "\n";
echo 'Attribute xml:lang exists?: ' . ($node->hasAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang') ? 'Yes' : 'No') . "\n";
$lang = $dom->createAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang');
$lang->nodeValue = 'en-GB';
$node->setAttributeNodeNS($lang);
unset($lang);
echo "Language: " . $node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang') . "\n";
$lang = $node->getAttributeNodeNS('http://www.w3.org/XML/1998/namespace', 'lang');
echo "Language: " . $lang->value . "\n";
echo "\n-- Elements --\n";
$rows = $node->getElementsByTagName('row');
echo "Row Count: " . $rows->length . "\n";
$element_ns = new DOMElement('newns:myelement', 'default content', 'urn::dummyns');
$node->appendChild($element_ns);
$element_ns = new DOMElement('newns2:myelement', 'second default content', 'urn::dummyns');
$node->appendChild($element_ns);
$myelements = $node->getElementsByTagNameNS('urn::dummyns', 'myelement');
$mylen = $myelements->length;
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:domelement.php


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