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


PHP object::getElementsByTagName方法代码示例

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


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

示例1: fixTableThScopes

 /**
  * Fixes table th scope errors
  * @param string $error_html     - The color(s) that need to be replaced
  * @param string $new_content    - The new CSS color(s) from the user
  * @param bool $submitting_again - If the user is resubmitting their error fix
  * @return string $fixed_ths     - The html with corrected th scopes
  */
 public function fixTableThScopes($error_html, $new_content, $submitting_again = false)
 {
     $this->dom->loadHTML('<?xml encoding="utf-8" ?>' . $error_html);
     $ths = $this->dom->getElementsByTagName('th');
     foreach ($ths as $th) {
         $th->setAttribute('scope', $new_content);
         $fixed_th = $this->dom->saveHTML($th);
     }
     return $fixed_th;
 }
开发者ID:jlagreca,项目名称:UDOIT,代码行数:17,代码来源:Ufixit.php

示例2: foreach

 /**
  * Constructor for a response message
  *
  * @param object $node A dom document node.
  */
 function __construct($node = null)
 {
     if (isset($node)) {
         foreach (get_class_vars('Services_W3C_HTMLValidator_Message') as $var => $val) {
             $element = $node->getElementsByTagName($var);
             if ($element->length) {
                 $this->{$var} = $element->item(0)->nodeValue;
             }
         }
     }
 }
开发者ID:wikidata,项目名称:wikidata,代码行数:16,代码来源:Message.php

示例3: pSimpleGetValue

 /**
  * pSimpleGetValue
  * Extrai o valor do node DOM
  *
  * @param  object                                        $theObj          Instancia de DOMDocument ou DOMElement
  * @param  string                                        $keyName         identificador da TAG do xml
  * @param  string                                        $extraTextBefore prefixo do retorno
  * @param  string extraTextAfter sufixo do retorno
  * @param  number itemNum numero do item a ser retornado
  * @return string
  */
 protected function pSimpleGetValue($theObj, $keyName, $extraTextBefore = '', $extraTextAfter = '', $itemNum = 0)
 {
     if (empty($theObj)) {
         return '';
     }
     //if (!($theObj instanceof DOMDocument) && !($theObj instanceof DOMElement)) {
     //    throw new nfephpException(
     //        "Metodo CommonNFePHP::pSimpleGetValue() "
     //        . "com parametro do objeto invalido, verifique!"
     //    );
     //}
     $vct = $theObj->getElementsByTagName($keyName)->item($itemNum);
     if (isset($vct)) {
         return $extraTextBefore . trim($vct->nodeValue) . $extraTextAfter;
     }
     return '';
 }
开发者ID:fmertins,项目名称:nfephp,代码行数:28,代码来源:CommonNFePHP.class.php

示例4: getControllers

 /**
  * Gets all controllers in the layout file. If a sector is specified
  * then get only those attached to that sector.
  *
  * @param string $inSector
  * @return array
  */
 public function getControllers($inSector = null)
 {
     if (empty($this->controllers)) {
         $cacheKey = 'layout_cntrlrs_' . $this->name;
         if (($this->controllers = $this->_cache->get($cacheKey)) == false) {
             $this->controllers = array();
             foreach ($this->dom->getElementsByTagName('controller') as $node) {
                 // Gather all configuration values
                 $config = array('displayTitle' => true, 'customTitle' => null, 'htmlWrapClass' => null);
                 foreach ($node->getElementsByTagName('config')->item(0)->childNodes as $confNode) {
                     $config[$confNode->nodeName] = $confNode->nodeValue;
                 }
                 // 2.3.51 changed attr 'for_sector' into 'sector', use older if exists
                 if (($sector = $node->getAttribute('for_sector')) == false) {
                     $sector = $node->getAttribute('sector');
                 }
                 // Store the controllers
                 $cid = $node->getAttribute('id');
                 $this->controllers[$cid] = array('id' => $cid, 'order' => (int) $node->getAttribute('order'), 'sector' => strtoupper($sector), 'mod' => $node->getElementsByTagName('mod')->item(0)->nodeValue, 'con' => $node->getElementsByTagName('con')->item(0)->nodeValue, 'sec' => $node->getElementsByTagName('sec')->item(0)->nodeValue, 'config' => $config);
             }
             // Normalize, order and cache the controllers
             zula_normalize($this->controllers);
             uasort($this->controllers, array($this, 'orderControllers'));
             $this->_cache->add($cacheKey, $this->controllers);
         }
     }
     if ($inSector == null) {
         return $this->controllers;
     } else {
         $inSector = strtoupper($inSector);
         $controllers = array();
         foreach ($this->controllers as $cntrlr) {
             if ($cntrlr['sector'] == $inSector) {
                 $controllers[$cntrlr['id']] = $cntrlr;
             }
         }
         return $controllers;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:46,代码来源:Layout.php

示例5: get_bbc

 /**
  * Loads the html body and sends it to the parsing loop to convert all
  * DOM nodes to BBC
  */
 public function get_bbc()
 {
     // For this html node, find all child elements and convert
     $body = $this->_parser ? $this->doc->getElementsByTagName('body')->item(0) : $this->doc->root;
     // Convert all the nodes that we know how to
     $this->_convert_childNodes($body);
     // Done replacing HTML elements, now get the converted DOM tree back into a string
     $bbc = $this->_parser ? $this->doc->saveHTML() : $this->doc->save();
     $bbc = $this->_recursive_decode($bbc);
     if ($this->_parser) {
         // Using the internal DOM methods we need to do a little extra work
         $bbc = html_entity_decode(htmlspecialchars_decode($bbc, ENT_QUOTES));
         if (preg_match('~<body>(.*)</body>~s', $bbc, $body)) {
             $bbc = $body[1];
         }
     }
     // Remove comment blocks
     $bbc = preg_replace('~\\<\\!--.*?-->~i', '', $bbc);
     $bbc = preg_replace('~\\<\\!\\[CDATA\\[.*?\\]\\]\\>~i', '', $bbc);
     // Remove non breakable spaces that may be hiding in here
     $bbc = str_replace("  ", ' ', $bbc);
     $bbc = str_replace(" ", ' ', $bbc);
     // Strip any excess leading/trailing blank lines we may have produced O:-)
     $bbc = trim($bbc);
     $bbc = preg_replace('~^(?:\\[br\\s*\\/?\\]\\s*)+~', '', $bbc);
     $bbc = preg_replace('~(?:\\[br\\s*\\/?\\]\\s*)+$~', '', $bbc);
     $bbc = str_replace('[hr][br]', '[hr]', $bbc);
     // Remove any html tags we left behind ( outside of code tags that is )
     $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $bbc, -1, PREG_SPLIT_DELIM_CAPTURE);
     for ($i = 0, $n = count($parts); $i < $n; $i++) {
         if ($i % 4 == 0) {
             $parts[$i] = strip_tags($parts[$i]);
         }
     }
     $bbc = implode('', $parts);
     return $bbc;
 }
开发者ID:scripple,项目名称:Elkarte,代码行数:41,代码来源:Html2BBC.class.php

示例6: path

 /**
  * 
  * @param type $limit
  * @param string $Path
  * @return type
  */
 public function path($limit = 1, $Path = '')
 {
     /** First Validation **/
     if (!trim($this->node)) {
         return array();
     }
     $this->dom = new DOMDocument();
     if ($this->path) {
         $this->dom->load($this->path);
     } elseif ($this->string) {
         $this->dom = new DOMDocument();
         @$this->dom->loadXML($this->string);
     }
     /** reset values array **/
     $this->values = array();
     $categories = $this->dom->getElementsByTagName($this->node);
     $tree = array();
     if (!trim($Path)) {
         $Path = '/' . $this->node . '/';
     }
     for ($i = 0; $i < $categories->length; $i++) {
         if ($i >= $limit) {
             break;
         }
         $cat = $categories->item($i);
         $childs = array();
         foreach ($cat->childNodes as $child) {
             if ($child->nodeType == XML_TEXT_NODE) {
                 continue;
             }
             $childs[$Path . $child->nodeName . '/'] = $this->childs($child, $Path . $child->nodeName . '/');
         }
         $tree[$i] = $childs;
     }
     return $tree;
 }
开发者ID:gvh1993,项目名称:project-vvvh,代码行数:42,代码来源:file.php

示例7: xmlByTagName

 /**
  *
  * @param string $psTag
  * @param object $poObject
  * @return object|NULL
  */
 public function xmlByTagName($psTag, &$poObject = null)
 {
     if ($poObject == null) {
         $poObject =& $this->coDocument;
     }
     if ($this->cbLoadOK) {
         $loList = $poObject->getElementsByTagName($psTag);
         if (is_object($loList) && $loList->length != 0) {
             return $loList;
         } else {
             return null;
         }
     }
 }
开发者ID:m3uzz,项目名称:onionfw,代码行数:20,代码来源:Sitemap.php

示例8: title

 /**
  * Returns powerpoint head title of a pptx based on its document object
  *
  * @param object $dom   a document object to extract a title from.
  * @return string  a title of the page
  *
  */
 static function title($dom)
 {
     $coreProperties = $dom->getElementsByTagName("coreProperties");
     $property = $coreProperties->item(0);
     $title = "";
     if ($property) {
         $titles = $property->getElementsByTagName("title");
         if ($titles->item(0)) {
             $title = $titles->item(0)->nodeValue;
         }
     }
     return $title;
 }
开发者ID:yakar,项目名称:yioop,代码行数:20,代码来源:docx_processor.php

示例9: _parseData

 /**
  * Read data from a string, and return a list of features. 
  * @return array of Feature instances
  */
 private function _parseData()
 {
     $types = array("NetworkLink", "Link", "Style", "StyleMap", "Placemark");
     foreach ($types as $type) {
         $nodes = $this->doc->getElementsByTagName($type);
         //getElementsByTagNameNS ?
         if ($nodes->length == 0) {
             continue;
         }
         // skip to next iteration
         //             Util::log($nodes->item(0)->nodeName, 'TYPE');
         switch (strtolower($type)) {
             // Fetch external links
             case "link":
             case "networklink":
                 $this->_parseLinks($nodes, $options);
                 break;
                 //
                 // parse style information
             //
             // parse style information
             case "style":
                 if ($this->extractStyles == true) {
                     $this->_parseStyles($nodes, $options);
                 }
                 break;
                 //
                 //             case "stylemap":
                 //               if(isset($this->_extractStyles)) {
                 //                 $this->_parseStyleMaps($nodes, $options);
                 //               }
                 //               break;
                 // parse features
             //
             //             case "stylemap":
             //               if(isset($this->_extractStyles)) {
             //                 $this->_parseStyleMaps($nodes, $options);
             //               }
             //               break;
             // parse features
             case "placemark":
                 $this->_parseFeatures($nodes, $options);
                 break;
         }
     }
     return $this->features;
 }
开发者ID:rccc,项目名称:simpleGeo,代码行数:51,代码来源:KML.class.php

示例10: numSlides

 /**
  * Returns number of slides of  pptx based on its document object
  *
  * @param object $dom   a document object to extract a title from.
  * @return number  number of slides
  *
  */
 static function numSlides($dom)
 {
     $properties = $dom->getElementsByTagName("Properties");
     $property = $properties->item(0);
     $slides = $property->getElementsByTagName("Slides");
     $number = $slides->item(0)->nodeValue;
     return $number;
 }
开发者ID:yakar,项目名称:yioop,代码行数:15,代码来源:pptx_processor.php

示例11: _convert_table

 /**
  * Converts tables tags to markdown extra table syntax
  *
  * - Have to build top down vs normal inside out due to needing col numbers and widths
  *
  * @param object $node
  */
 private function _convert_table($node)
 {
     $table_heading = $node->getElementsByTagName('th');
     if ($this->_get_item($table_heading, 0) === null) {
         return;
     }
     $th_parent = $table_heading ? $this->_parser ? $this->_get_item($table_heading, 0)->parentNode->nodeName : $this->_get_item($table_heading, 0)->parentNode()->nodeName() : false;
     // Set up for a markdown table, then storm the castle
     $align = array();
     $value = array();
     $width = array();
     $max = array();
     $header = array();
     $rows = array();
     // We only markdown well formed tables ...
     if ($table_heading && $th_parent === 'tr') {
         // Find out how many columns we are dealing with
         $th_num = $this->_get_length($table_heading);
         for ($col = 0; $col < $th_num; $col++) {
             // Get the align and text for each th (html5 this is no longer valid)
             $th = $this->_get_item($table_heading, $col);
             $align_value = $th !== null ? strtolower($th->getAttribute('align')) : false;
             $align[0][$col] = $align_value === false ? 'left' : $align_value;
             $value[0][$col] = $this->_get_value($th);
             $width[0][$col] = Util::strlen($this->_get_value($th));
             // Seed the max col width
             $max[$col] = $width[0][$col];
         }
         // Get all of the rows
         $table_rows = $node->getElementsByTagName('tr');
         $num_rows = $this->_get_length($table_rows);
         for ($row = 1; $row < $num_rows; $row++) {
             // Start at row 1 and get all of the td's in this row
             $row_data = $this->_get_item($table_rows, $row)->getElementsByTagName('td');
             // Simply use the th count as the number of columns, if its not right its not markdown-able anyway
             for ($col = 0; $col < $th_num; $col++) {
                 // Get the align and text for each td in this row
                 $td = $this->_get_item($row_data, $col);
                 $align_value = $td !== null ? strtolower($td->getAttribute('align')) : false;
                 $align[$row][$col] = $align_value === false ? 'left' : $align_value;
                 $value[$row][$col] = $this->_get_value($td);
                 $width[$row][$col] = Util::strlen($this->_get_value($td));
                 // Keep track of the longest col cell as we go
                 if ($width[$row][$col] > $max[$col]) {
                     $max[$col] = $width[$row][$col];
                 }
             }
         }
         // Done collecting data, we can rebuild it, we can make it better than it was. Better...stronger...faster
         for ($row = 0; $row < $num_rows; $row++) {
             $temp = array();
             for ($col = 0; $col < $th_num; $col++) {
                 // Build the header row once
                 if ($row === 0) {
                     $header[] = str_repeat('-', $max[$col]);
                 }
                 // Build the data for each col, align/pad as needed
                 $temp[] = $this->_align_row_content($align[$row][$col], $width[$row][$col], $value[$row][$col], $max[$col]);
             }
             // Join it all up so we have a nice looking row
             $rows[] = '| ' . implode(' | ', $temp) . ' |';
             // Stuff in the header after the th row
             if ($row === 0) {
                 $rows[] = '| ' . implode(' | ', $header) . ' | ';
             }
         }
         // Adjust the word wrapping since this has a table, will get mussed by email anyway
         $line_strlen = strlen($rows[1]) + 2;
         if ($line_strlen > $this->body_width) {
             $this->body_width = $line_strlen;
         }
         // Return what we did so it can be swapped in
         return implode($this->line_end, $rows);
     }
 }
开发者ID:scripple,项目名称:Elkarte,代码行数:82,代码来源:Html2Md.class.php

示例12: upgrade0To1

 /**
  * do all necessary changes from version 0 to version 1
  */
 protected function upgrade0To1()
 {
     // @see http://cometvisu.de/wiki/index.php?title=CometVisu/Update
     $objXPath = new DOMXPath($this->objDOM);
     // append namespaces to schema
     $this->objDOM->getElementsByTagName('pages')->item(0)->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $this->objDOM->getElementsByTagName('pages')->item(0)->setAttribute('xsi:noNamespaceSchemaLocation', '../visu_config.xsd');
     // rename iframe to web
     $objElements = $objXPath->query('//iframe');
     $i = 0;
     foreach ($objElements as $objElement) {
         $this->renameNode($objElement, 'web');
         ++$i;
     }
     $this->log('renamed ' . $i . ' nodes of type \'iframe\' to \'web\'');
     unset($objElements, $i);
     // change diagram_popup to diagram
     $objElements = $objXPath->query('//diagram_popup');
     $i = 0;
     foreach ($objElements as $objElement) {
         $objElement->setAttribute('popup', 'true');
         $objElement->setAttribute('previewlabels', 'false');
         $objElement->setAttribute('legend', 'popup');
         $this->renameNode($objElement, 'diagram');
         ++$i;
     }
     $this->log('changed ' . $i . ' nodes of type \'diagram_popup\' to \'diagram\'');
     unset($objElements);
     // change diagram_inline to diagram
     $objElements = $objXPath->query('//diagram_inline');
     $i = 0;
     foreach ($objElements as $objElement) {
         $objElement->setAttribute('popup', 'false');
         $objElement->setAttribute('previewlabels', 'true');
         $objElement->setAttribute('legend', 'none');
         $this->renameNode($objElement, 'diagram');
         ++$i;
     }
     $this->log('changed ' . $i . ' nodes of type \'diagram_inline\' to \'diagram\'');
     unset($objElements);
     // move diagram attributes to child-nodes
     $objElements = $objXPath->query('//diagram|//diagram_info');
     $i = 0;
     foreach ($objElements as $objElementNode) {
         if ($objElementNode->hasAttribute('rrd')) {
             // create rrdnode
             $objRRDNode = $objElementNode->ownerDocument->createElement('rrd');
             $rrdContent = $objElementNode->ownerDocument->createTextNode($objElementNode->getAttribute('rrd'));
             $objRRDNode->appendChild($rrdContent);
             if ($objElementNode->hasAttribute('linecolor')) {
                 $objRRDNode->setAttribute('color', $objElementNode->getAttribute('linecolor'));
             }
             $objElementNode->removeAttribute('rrd');
             $objElementNode->appendChild($objRRDNode);
         }
         if ($objElementNode->hasAttribute('linecolor')) {
             $objElementNode->removeAttribute('linecolor');
         }
         $objAxisNode = $objElementNode->ownerDocument->createElement('axis');
         $addAxis = false;
         if ($objElementNode->hasAttribute('yaxismin')) {
             $objAxisNode->setAttribute('min', $objElementNode->getAttribute('yaxismin'));
             $objElementNode->removeAttribute('yaxismin');
             $addAxis = true;
         }
         if ($objElementNode->hasAttribute('yaxismax')) {
             $objAxisNode->setAttribute('max', $objElementNode->getAttribute('yaxismax'));
             $objElementNode->removeAttribute('yaxismax');
             $addAxis = true;
         }
         if ($objElementNode->hasAttribute('unit')) {
             $objAxisNode->setAttribute('unit', $objElementNode->getAttribute('unit'));
             $objElementNode->removeAttribute('unit');
             $addAxis = true;
         }
         if ($addAxis) {
             $objElementNode->appendChild($objAxisNode);
         }
         ++$i;
     }
     $this->log('moved attributes to childs in  ' . $i . ' nodes of type \'diagram(_info)\' ');
     unset($objElements);
     // remove whitespace-attributes
     $objAttributes = $objXPath->query('//@*[.=\' \']');
     $i = 0;
     foreach ($objAttributes as $objAttribute) {
         $objAttribute->ownerElement->removeAttributeNode($objAttribute);
         ++$i;
     }
     $this->log('removed ' . $i . ' empty-like attributes');
     // remove empty attributes
     $objAttributes = $objXPath->query('//@*[.=\'\']');
     $i = 0;
     foreach ($objAttributes as $objAttribute) {
         $objAttribute->ownerElement->removeAttributeNode($objAttribute);
         ++$i;
     }
//.........这里部分代码省略.........
开发者ID:mcdeck,项目名称:CometVisu,代码行数:101,代码来源:ConfigurationUpgrader.class.php

示例13: render

 /**
  * Method to build the final structure
  *
  * @return void
  */
 public function render()
 {
     $return = '';
     if ($this->render == true) {
         //insert the html content
         foreach (array_keys($this->data) as $id) {
             if ($this->DOM->getElementById($id) == false) {
                 if ($id == $this->Config->template['content_div']) {
                     throw new Exception('Cannot locate content div');
                 }
                 continue;
             }
             if (isset($this->data[$id])) {
                 $append = $this->DOM->importNode($this->data[$id]->documentElement->getElementsByTagName($this->delimiter)->item(0), true);
                 $this->DOM->getElementById($id)->appendChild($append);
             }
         }
         //insert css links
         if (!empty($this->css)) {
             if ($header = $this->DOM->getElementsByTagName('head')->item(0)) {
                 foreach ($this->css as $css) {
                     $link = $this->DOM->createElement('link');
                     $link->setAttribute('type', 'text/css');
                     $link->setAttribute('rel', 'stylesheet');
                     $link->setAttribute('href', $css);
                     $header->appendChild($link);
                 }
             }
         }
         //insert js links
         if (!empty($this->js)) {
             if ($header = $this->DOM->getElementsByTagName('body')->item(0)) {
                 foreach ($this->js as $js) {
                     $script = $this->DOM->createElement('script');
                     $script->setAttribute('type', 'text/javascript');
                     $script->setAttribute('src', $js);
                     $header->appendChild($script);
                 }
             }
         }
         //set all the attributes
         foreach ($this->attributes as $id => $attribute) {
             if ($this->DOM->getElementById($id)) {
                 $this->DOM->getElementById($id)->setAttribute($attribute[0], $attribute[1]);
             }
         }
         $pattern = array("/<\\/?{$this->delimiter}.*?>/");
         if ($this->compact == false) {
             $pattern[] = "/<!--\\[.*?\\]-->|<!--.*?-->|\\s{2,}|\r|\t|\n/";
         }
         $return = preg_replace($pattern, '', $this->DOM->saveHTML());
         if (preg_match_all("/(<(area|base|basefont|br|col|frame|hr|img|input|link|meta|param).*?>)/", $return, $matches) > 0) {
             foreach ($matches[0] as $match) {
                 $replace[] = substr($match, 0, -1) . '/>';
             }
         }
         $return = str_replace($matches[0], $replace, $return);
     } else {
         if (isset($this->data['content'])) {
             $return = $this->data['content'];
         }
     }
     echo $return;
 }
开发者ID:rogerluiz,项目名称:Toolkitty,代码行数:69,代码来源:Template.php

示例14: _parseGate

 /**
  * Build an individual gate file
  *
  * @param object &$gate reference to gate object
  *
  * @return string content of gate to write
  */
 private function _parseGate(&$gate)
 {
     //init array for required file
     $required = array();
     $code = '';
     //foreach action
     $this->_parseGateCallback($gate, $code, $required);
     //get prepend tags
     $res = $this->sitemapDocument->getElementsByTagName('prepend');
     $prependCode = '';
     if ($res->length) {
         $prependGate = $res->item(0);
         $this->_parseGateCallback($prependGate, $prependCode, $required);
     }
     //add header and required files
     $content = $this->_addGateHeader($gate, $required);
     //add prepend and main code
     $content .= $prependCode . $code;
     $content .= $this->_addGateFooter($gate);
     return $content;
 }
开发者ID:savonix,项目名称:nexista,代码行数:28,代码来源:foundry.php

示例15: __construct

 /**
  * Constructor for a response message
  *
  * @param object $node A DOM document node.
  *
  * @return void
  */
 public function __construct($node = null)
 {
     if (isset($node)) {
         $properties = get_object_vars($this);
         foreach ($properties as $var => $val) {
             $element = $node->getElementsByTagName($var);
             if ($element->length) {
                 $this->{$var} = $element->item(0)->nodeValue;
             }
         }
     }
 }
开发者ID:bevello,项目名称:bevello,代码行数:19,代码来源:Message.php


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