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


PHP DOMNode类代码示例

本文整理汇总了PHP中DOMNode的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode类的具体用法?PHP DOMNode怎么用?PHP DOMNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getXml

 /**
  * @param \DOMNode $parent
  * @param SerializationContext $context
  * @return \DOMElement
  */
 public function getXml(\DOMNode $parent, SerializationContext $context)
 {
     $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:NameIDFormat');
     $parent->appendChild($result);
     $result->nodeValue = $this->value;
     return $result;
 }
开发者ID:LearnerNation,项目名称:lightsaml,代码行数:12,代码来源:NameIDFormat.php

示例2: getStateXML

 /**
  * Get some configuration variables as XML node attributes
  * @param \DOMElement|\DOMNode $node
  */
 public static function getStateXML($node)
 {
     $config = self::getState();
     foreach ($config as $k => $v) {
         $node->setAttribute($k, $v);
     }
 }
开发者ID:difra-org,项目名称:difra,代码行数:11,代码来源:Envi.php

示例3: append_style

 static function append_style(DOMNode $node, $new_style)
 {
     $style = rtrim($node->getAttribute(self::$_style_attr), ";");
     $style .= $new_style;
     $style = ltrim($style, ";");
     $node->setAttribute(self::$_style_attr, $style);
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:7,代码来源:attribute_translator.cls.php

示例4: _buildNode

 /**
  * Builds and creates the Atom XML nodes required by this date
  *
  * The element node representing this date is created separately and
  * passed as the first parameter of this method.
  *
  * @param DOMNode $node the node representing this date.
  *
  * @return void
  */
 protected function _buildNode(DOMNode $node)
 {
     $document = $node->ownerDocument;
     $date_string = $this->_date->format('c');
     $text_node = $document->createTextNode($date_string);
     $node->appendChild($text_node);
 }
开发者ID:gauthierm,项目名称:xml-atom,代码行数:17,代码来源:Date.php

示例5: _nodeToValue

 /**
  * Converts a node to a PHP value
  *
  * @param DOMNode $node
  * @return mixed
  */
 private static function _nodeToValue($node)
 {
     $type = null;
     if ($node instanceof DOMElement) {
         $type = $node->getAttribute('type');
     }
     switch ($type) {
         case 'datetime':
             return self::_timestampToUTC((string) $node->nodeValue);
         case 'date':
             return new DateTime((string) $node->nodeValue);
         case 'integer':
             return (int) $node->nodeValue;
         case 'boolean':
             $value = (string) $node->nodeValue;
             if (is_numeric($value)) {
                 return (bool) $value;
             } else {
                 return $value !== "true" ? false : true;
             }
         case 'array':
         case 'collection':
             return self::_nodeToArray($node);
         default:
             if ($node->hasChildNodes()) {
                 return self::_nodeToArray($node);
             } elseif (trim($node->nodeValue) === '') {
                 return null;
             } else {
                 return $node->nodeValue;
             }
     }
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:39,代码来源:Parser.php

示例6: processDataTag

	private function processDataTag( DOMNode $node ) {
		if( $node->hasAttribute( DATA_TYPE_ATTRIBUTE_NAME ) ) {
			switch( $node->getAttribute( DEPENDENCY_TYPE_ATTRIBUTE_NAME ) ) {
				case DATA_TYPE_STREAM_VALUE:
				/******* nothing for now
					$url = $this->buildURL( MODULE_STREAM_PATH . $node->nodeValue );
					if( $this->url_exists( $url ) ) {
						$this->xml->load( $url );
					}
				**********/
					break;
				case DATA_TYPE_PROCESSOR_VALUE:

					break;
				case DATA_TYPE_DYNAMICFILE_VALUE:
					if ( file_exists( MODULE_FILE_PATH . $node->nodeValue ) ) {
						ob_start();
						$file = MODULE_FILE_PATH . $node->nodeValue;
						include $file;
						$this->dynamicFileOutput .= ob_get_contents();
						ob_end_clean();
					}
					break;
				case DATA_TYPE_STATICFILE_VALUE:
					if ( file_exists( MODULE_FILE_PATH . $node->nodeValue ) ) {
						$this->staticFileOutput .= file_get_contents( MODULE_FILE_PATH . $node->nodeValue );
					} else {
						
						//echo "loading: " . MODULE_FILE_PATH . $node->nodeValue;
					}
					break;
			}
		}
	}
开发者ID:nathanfl,项目名称:medtele,代码行数:34,代码来源:Module.Class.php

示例7: drawThumbnailZone

 /**
  * Draw a final layout zone on its thumbnail.
  *
  * @access private
  *
  * @param ressource $thumbnail  The thumbnail ressource
  * @param DOMNode   $node       The current node zone
  * @param array     $clip       The clip rect to draw
  * @param int       $background The background color
  * @param int       $gridcolumn The number of columns in the grid
  * @param boolean   $lastChild  True if the current node is the last child of its parent node
  *
  * @return int The new X axis position;
  */
 private function drawThumbnailZone(&$thumbnail, $node, $clip, $background, $gridcolumn, $lastChild = false)
 {
     $x = $clip[0];
     $y = $clip[1];
     $width = $clip[2];
     $height = $clip[3];
     if (null !== ($spansize = preg_replace('/[^0-9]+/', '', $node->getAttribute('class')))) {
         $width = floor($width * $spansize / $gridcolumn);
     }
     if (false !== strpos($node->getAttribute('class'), 'Child')) {
         $height = floor($height / 2);
     }
     if (!$node->hasChildNodes()) {
         $this->drawRect($thumbnail, array($x, $y, $width, $height), $background, $width == $clip[2] || strpos($node->getAttribute('class'), 'hChild'), $lastChild);
         return $width + 2;
     }
     foreach ($node->childNodes as $child) {
         if (is_a($child, 'DOMText')) {
             continue;
         }
         if ('clear' == $child->getAttribute('class')) {
             $x = $clip[0];
             $y = $clip[1] + floor($height / 2) + 2;
             continue;
         }
         $x += $this->drawThumbnailZone($thumbnail, $child, array($x, $y, $clip[2], $height), $background, $gridcolumn, $node->isSameNode($node->parentNode->lastChild));
     }
     return $x + $width - 2;
 }
开发者ID:gobjila,项目名称:BackBee,代码行数:43,代码来源:LayoutRepository.php

示例8: recursiveStripQuotes

function recursiveStripQuotes(DOMNode $node)
{
    if (!$node->childNodes) {
        return;
    }
    $purge = array();
    foreach ($node->childNodes as $child) {
        $class = null;
        if ($child->attributes) {
            $class = $child->attributes->getNamedItem('class');
        }
        if ($class && $class->value == 'quoteheader') {
            $purge[] = $child;
        } elseif ($class && $class->value == 'quotefooter') {
            $purge[] = $child;
        } elseif ($child->nodeName == 'blockquote') {
            $purge[] = $child;
        } else {
            recursiveStripQuotes($child);
        }
    }
    foreach ($purge as $child) {
        $node->removeChild($child);
    }
    return $node;
}
开发者ID:ErikRoelofs,项目名称:wordcounter,代码行数:26,代码来源:index.php

示例9: getXml

 /**
  * @param \DOMNode $parent
  * @param \AerialShip\LightSaml\Meta\SerializationContext $context
  * @return \DOMNode
  */
 function getXml(\DOMNode $parent, SerializationContext $context)
 {
     $objXMLSecDSig = new \XMLSecurityDSig();
     $objXMLSecDSig->setCanonicalMethod($this->getCanonicalMethod());
     $key = $this->getXmlSecurityKey();
     switch ($key->type) {
         case \XMLSecurityKey::RSA_SHA256:
             $type = \XMLSecurityDSig::SHA256;
             break;
         case \XMLSecurityKey::RSA_SHA384:
             $type = \XMLSecurityDSig::SHA384;
             break;
         case \XMLSecurityKey::RSA_SHA512:
             $type = \XMLSecurityDSig::SHA512;
             break;
         default:
             $type = \XMLSecurityDSig::SHA1;
     }
     $objXMLSecDSig->addReferenceList(array($parent), $type, array(Protocol::XMLSEC_TRANSFORM_ALGORITHM_ENVELOPED_SIGNATURE, \XMLSecurityDSig::EXC_C14N), array('id_name' => $this->getIDName(), 'overwrite' => FALSE));
     $objXMLSecDSig->sign($key);
     $objXMLSecDSig->add509Cert($this->getCertificate()->getData(), false, false);
     $firstChild = $parent->hasChildNodes() ? $parent->firstChild : null;
     if ($firstChild && $firstChild->localName == 'Issuer') {
         // The signature node should come after the issuer node
         $firstChild = $firstChild->nextSibling;
     }
     $objXMLSecDSig->insertSignature($parent, $firstChild);
 }
开发者ID:LearnerNation,项目名称:lightsaml,代码行数:33,代码来源:SignatureCreator.php

示例10: checkPageLink

 /**
  * Check the status of a single link on a page
  *
  * @param BrokenExternalPageTrack $pageTrack
  * @param DOMNode $link
  */
 protected function checkPageLink(BrokenExternalPageTrack $pageTrack, DOMNode $link)
 {
     $class = $link->getAttribute('class');
     $href = $link->getAttribute('href');
     $markedBroken = preg_match('/\\b(ss-broken)\\b/', $class);
     // Check link
     $httpCode = $this->linkChecker->checkLink($href);
     if ($httpCode === null) {
         return;
     }
     // Null link means uncheckable, such as an internal link
     // If this code is broken then mark as such
     if ($foundBroken = $this->isCodeBroken($httpCode)) {
         // Create broken record
         $brokenLink = new BrokenExternalLink();
         $brokenLink->Link = $href;
         $brokenLink->HTTPCode = $httpCode;
         $brokenLink->TrackID = $pageTrack->ID;
         $brokenLink->StatusID = $pageTrack->StatusID;
         // Slight denormalisation here for performance reasons
         $brokenLink->write();
     }
     // Check if we need to update CSS class, otherwise return
     if ($markedBroken == $foundBroken) {
         return;
     }
     if ($foundBroken) {
         $class .= ' ss-broken';
     } else {
         $class = preg_replace('/\\s*\\b(ss-broken)\\b\\s*/', ' ', $class);
     }
     $link->setAttribute('class', trim($class));
 }
开发者ID:govtnz,项目名称:silverstripe-externallinks,代码行数:39,代码来源:CheckExternalLinksTask.php

示例11: copyNodes

 protected function copyNodes(DOMNode $dirty, DOMNode $clean)
 {
     foreach ($dirty->attributes as $name => $valueNode) {
         /* Copy over allowed attributes */
         if (isset($this->allowed[$dirty->nodeName][$name])) {
             $attr = $clean->ownerDocument->createAttribute($name);
             $attr->value = $valueNode->value;
             $clean->appendChild($attr);
         }
     }
     foreach ($dirty->childNodes as $child) {
         /* Copy allowed elements */
         if ($child->nodeType == XML_ELEMENT_NODE && isset($this->allowed[$child->nodeName])) {
             $node = $clean->ownerDocument->createElement($child->nodeName);
             $clean->appendChild($node);
             /* Examine children of this allowed element */
             $this->copyNodes($child, $node);
         } else {
             if ($child->nodeType == XML_TEXT_NODE) {
                 $text = $clean->ownerDocument->createTextNode($child->textContent);
                 $clean->appendChild($text);
             }
         }
     }
 }
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:25,代码来源:tag-stripper.php

示例12: appendToDom

 public function appendToDom(\DOMNode $parent)
 {
     $node = $parent->appendChild(new \DOMElement('PaymentAccount'));
     $node->appendChild(new \DOMElement('PaymentAccountID', $this['PaymentAccountID']));
     $node->appendChild(new \DOMElement('PaymentAccountType', $this['PaymentAccountType']));
     $node->appendChild(new \DOMElement('PaymentAccountReferenceNumber', $this['PaymentAccountReferenceNumber']));
 }
开发者ID:zerve,项目名称:omnipay-elementexpress,代码行数:7,代码来源:PaymentAccount.php

示例13: castElement

 /**
  * Caste l'élement spécifié
  *
  * @param DOMNode $nodeParent DOMNode
  * @param String  $value      String
  *
  * @return void
  */
 function castElement($nodeParent, $value)
 {
     $value = utf8_encode($value);
     $attribute = $this->createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:type");
     $attribute->nodeValue = $value;
     $nodeParent->appendChild($attribute);
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:15,代码来源:CCDADomDocument.class.php

示例14: 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);
             }
         }
     }
 }
开发者ID:difra-org,项目名称:difra,代码行数:37,代码来源:DOM.php

示例15: process

 /**
  * @param DOMNode $node
  * @param ProxyObject $proxy
  */
 private function process(DOMNode $node, ProxyObject $proxy)
 {
     $proxy->setName($node->nodeName);
     if ($node->hasAttributes()) {
         for ($i = 0; $i < $node->attributes->length; $i++) {
             $attribute = $node->attributes->item($i);
             $proxy->set($attribute->name, $attribute->value);
         }
     }
     if ($node->hasChildNodes()) {
         $nodeTypes = array();
         foreach ($node->childNodes as $childNode) {
             if ($childNode->nodeName === '#text') {
                 $proxy->setValue($childNode->nodeValue);
             } else {
                 $childProxy = new ProxyObject();
                 $this->process($childNode, $childProxy);
                 $nodeTypes[$childProxy->getName()][] = $childProxy;
             }
         }
         foreach ($nodeTypes as $tagName => $nodes) {
             $proxy->set($tagName, $nodes);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:chrisahhh-silverstripe-importer,代码行数:29,代码来源:XmlDataSource.php


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