當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。