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


PHP DOMElement::getElementsByTagName方法代码示例

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


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

示例1: createMap

 /**
  * @param callable $rowParseCallback
  * @param callable $cellParseCallback
  * @return void
  */
 public function createMap(\Closure $rowParseCallback = null, \Closure $cellParseCallback = null)
 {
     // First, dos ome basic cleanup
     $this->cleanupTable();
     // Then, get all rows and parse!
     $trs = $this->table->getElementsByTagName('tr');
     if ($trs instanceof \DOMNodeList && $trs->length > 0) {
         for ($tri = 0, $rowGroupi = 0; $tri < $trs->length; $rowGroupi++) {
             /** @var \DOMElement $tr */
             $tr = $trs->item($tri);
             $this->rowOffsets[$rowGroupi] = array('firstRow' => $tri);
             $this->rowCellMap[$rowGroupi] = array();
             $this->rowGroups[$rowGroupi] = array();
             $rowSpan = 1;
             foreach ($tr->childNodes as $child) {
                 /** @var $child \DOMElement */
                 if ($child->hasAttribute('rowspan') && (int) $child->getAttribute('rowspan') > $rowSpan) {
                     $rowSpan = (int) $child->getAttribute('rowspan');
                 }
             }
             $this->parseRowGroup($this->rowCellMap[$rowGroupi], $this->rowGroups[$rowGroupi], $rowSpan, $tr, $rowParseCallback, $cellParseCallback);
             $tri += $rowSpan;
             $this->rowOffsets[$rowGroupi]['lastRow'] = $tri > 0 ? $tri - 1 : $tri;
         }
     }
 }
开发者ID:dcarbone,项目名称:table-mapper,代码行数:31,代码来源:TableMapper.php

示例2: __construct

 /**
  * Creates a new CqOption.
  *
  * @param DOMElement $node
  *   containing the option definition
  * @param CqQuestionInterface $context
  *   CqQuestionInterface The question or other object that the mapping can query for
  *   things like the current answer, draggables, hotspots and the parsing of
  *   html.
  */
 public function __construct(DOMElement $node, $context)
 {
     foreach ($node->getElementsByTagName('choice') as $choice) {
         $this->text .= cq_get_text_content($choice, $context);
     }
     foreach ($node->getElementsByTagName('description') as $description) {
         $this->description .= cq_get_text_content($description, $context);
     }
     foreach ($node->getElementsByTagName('feedback') as $fb) {
         $this->feedback[] = CqFeedback::newCqFeedback($fb, $context);
     }
     foreach ($node->getElementsByTagName('feedbackunselected') as $fb) {
         $this->feedbackUnselected[] = CqFeedback::newCqFeedback($fb, $context);
     }
     $attribs = $node->attributes;
     $item = $attribs->getNamedItem('correct');
     if ($item !== NULL) {
         $this->correct = (int) $item->value;
     }
     $item = $attribs->getNamedItem('identifier');
     if ($item === NULL) {
         $item = $attribs->getNamedItem('id');
     }
     if ($item === NULL) {
         $item = $attribs->getNamedItem('name');
     }
     if ($item !== NULL) {
         $this->identifier = $item->nodeValue;
     }
 }
开发者ID:rollinsb1010,项目名称:elearning,代码行数:40,代码来源:CqOption.class.php

示例3: getValue

 /**
  * getValue
  * @param DOMElement $node
  * @param string $name
  * @return string
  */
 public function getValue($node, $name)
 {
     if (empty($node)) {
         return '';
     }
     $texto = !empty($node->getElementsByTagName($name)->item(0)->nodeValue) ? $node->getElementsByTagName($name)->item(0)->nodeValue : '';
     return html_entity_decode($texto, ENT_QUOTES, 'UTF-8');
 }
开发者ID:JulianoAmaralChaves,项目名称:nfephp,代码行数:14,代码来源:Dom.php

示例4: getOptionalField

 private function getOptionalField($fieldName, $attributeName = null)
 {
     $value = '';
     $tag = $this->currentVideo->getElementsByTagName($fieldName);
     if ($tag->length) {
         $value = is_null($attributeName) ? $tag->item(0)->textContent : $tag->item(0)->getAttribute($attributeName);
     }
     return $value;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:MakerstudiosFeedIngester.class.php

示例5: _downloadTestData

 /**
  * テストデータをダウンロードする
  *
  * @param  DOMElement $item
  * @return string
  **/
 private function _downloadTestData($item)
 {
     $url = $item->getElementsByTagName('link')->item(0)->nodeValue;
     if ($url === '') {
         $url = $item->getElementsByTagName('link')->item(0)->getAttribute('href');
     }
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($curl);
     curl_close($curl);
     return $result;
 }
开发者ID:kknet,项目名称:AdultMidnight,代码行数:19,代码来源:UpdateTestData.php

示例6: applyXMLElement

 public function applyXMLElement(\DOMElement $element)
 {
     $this->_alpha2 = $element->getAttribute('code');
     $listXMLNode = $element->getElementsByTagName('iso_3166_subset');
     // check if country has sub divisions
     if (!$listXMLNode->length) {
         return;
     }
     // get sub division type
     $this->_subDivisionName = $listXMLNode->item(0)->getAttribute('type');
     foreach ($element->getElementsByTagName('iso_3166_2_entry') as $element) {
         $this->_list[$element->getAttribute('code')] = $element->getAttribute('name');
     }
 }
开发者ID:sokil,项目名称:php-isocodes,代码行数:14,代码来源:Subdivision.php

示例7: convertXMLToRelation

 /**
  * Converts a DOMElement item to a Zotero_Relation object
  *
  * @param	DOMElement			$xml		Relation data as DOM element
  * @param	Integer				$libraryID
  * @return	Zotero_Relation					Zotero relation object
  */
 public static function convertXMLToRelation(DOMElement $xml, $userLibraryID)
 {
     $relation = new Zotero_Relation();
     $libraryID = $xml->getAttribute('libraryID');
     if ($libraryID) {
         $relation->libraryID = $libraryID;
     } else {
         $relation->libraryID = $userLibraryID;
     }
     $relation->subject = $xml->getElementsByTagName('subject')->item(0)->nodeValue;
     $relation->predicate = $xml->getElementsByTagName('predicate')->item(0)->nodeValue;
     $relation->object = $xml->getElementsByTagName('object')->item(0)->nodeValue;
     return $relation;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:21,代码来源:Relations.inc.php

示例8: appendComment

 public function appendComment(DOMElement $changeset, array $row)
 {
     $dom_node_list = $changeset->getElementsByTagName('comments');
     $comments_node = $dom_node_list->item(0);
     $this->all_comments[$row['id']] = $comments_node;
     $comments_node->appendChild($this->createCommentNode($row));
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:ArtifactCommentXMLExporter.class.php

示例9: handleImages

 /**
  *
  * @param DOMElement $dom
  * @return array
  */
 private function handleImages($dom, $url)
 {
     $images = array();
     $parts = parse_url($url);
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         $parsed = parse_url($src);
         if (!isset($parsed["host"])) {
             if ($is_root) {
                 $src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
             } else {
                 $src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
             }
         }
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     return $images;
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:40,代码来源:OnlineArticle.php

示例10: unserializeContentClassAttribute

 /**
  * Unserialize contentclass attribute
  *
  * @param eZContentClassAttribute $classAttribute
  * @param DOMElement $attributeNode
  * @param DOMElement $attributeParametersNode
  */
 function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
 {
     $defaultZoneLayoutItem = $attributeParametersNode->getElementsByTagName('default-layout')->item(0);
     if ($defaultZoneLayoutItem !== null && $defaultZoneLayoutItem->textContent !== false) {
         $classAttribute->setAttribute(self::DEFAULT_ZONE_LAYOUT_FIELD, $defaultZoneLayoutItem->textContent);
     }
 }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:14,代码来源:ezpagetype.php

示例11: extractImages

 /**
  * Extract <img> elements
  *
  * @param \DOMElement $html
  * @param Bag         $bag
  * @param null|string $domain
  */
 protected static function extractImages(\DOMElement $html, Bag $bag, $domain = null)
 {
     foreach ($html->getElementsByTagName('img') as $img) {
         self::addByAttribute($img, 'src', $html, $bag, $domain);
         self::addByAttribute($img, 'data-src', $html, $bag, $domain);
     }
 }
开发者ID:jooorooo,项目名称:embed,代码行数:14,代码来源:Ebay.php

示例12: update

 function update(DOMElement $item)
 {
     $title = $item->getElementsByTagName('title');
     $description = $item->getElementsByTagName('description');
     $pubDate = $item->getElementsByTagName('pubDate');
     $link = $item->getElementsByTagName('link');
     $nodeEnclosure = $item->getElementsByTagName('enclosure');
     $this->titre = $title->item(0)->textContent;
     $this->description = $description->item(0)->textContent;
     $this->date = $pubDate->item(0)->textContent;
     $this->url = $link->item(0)->textContent;
     if ($nodeEnclosure != NULL) {
         $this->image = $nodeEnclosure->item(0)->attributes->getNamedItem('url')->nodeValue;
     } else {
         $this->image = "default";
     }
 }
开发者ID:Nelgamix,项目名称:PHP_Projet,代码行数:17,代码来源:Nouvelle.class.php

示例13: configurationFromXML

 /**
  * Generate node configuration from XML representation.
  *
  * @param DOMElement $element
  * @return array
  * @ignore
  */
 public static function configurationFromXML(DOMElement $element)
 {
     $configuration = array();
     foreach ($element->getElementsByTagName('variable') as $variable) {
         $configuration[] = $variable->getAttribute('name');
     }
     return $configuration;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:15,代码来源:unset.php

示例14: configurationFromXML

 /**
  * Generate node configuration from XML representation.
  *
  * @param DOMElement $element
  * @return array
  * @ignore
  */
 public static function configurationFromXML(DOMElement $element)
 {
     $configuration = array();
     foreach ($element->getElementsByTagName('variable') as $variable) {
         $configuration[$variable->getAttribute('name')] = ezcWorkflowDefinitionStorageXml::xmlToVariable(ezcWorkflowUtil::getChildNode($variable));
     }
     return $configuration;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:15,代码来源:set.php

示例15: getVocations

 /**
  * Returns list of vocations that are allowed to learn this spell.
  * 
  * @return array List of vocation names.
  * @throws DOMException On DOM operation error.
  */
 public function getVocations()
 {
     $vocations = array();
     foreach ($this->element->getElementsByTagName('vocation') as $vocation) {
         $vocations[] = $vocation->getAttribute('name');
     }
     return $vocations;
 }
开发者ID:Codex-NG,项目名称:poketibia,代码行数:14,代码来源:OTS_Spell.php


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