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


PHP Node::setAttribute方法代码示例

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


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

示例1: attributeAccessors

 public function attributeAccessors()
 {
     $n = new Node('node');
     $n->setAttribute('id', 1);
     $this->assertTrue($n->hasAttribute('id'));
     $this->assertFalse($n->hasAttribute('href'));
     $this->assertEquals(1, $n->getAttribute('id'));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:8,代码来源:NodeTest.class.php

示例2: applyArgs

 protected function applyArgs(Node $node)
 {
     if ($node instanceof TextNode) {
         $node->setContent($this->interpolate($node->getContent()));
     } else {
         if ($node instanceof Element) {
             foreach ($node->getAttributes() as $attr => $value) {
                 $node->setAttribute($attr, $this->interpolate($value));
             }
         }
     }
     foreach ($node->getChildren() as $child) {
         $this->applyArgs($child);
     }
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:15,代码来源:IncludeElement.php

示例3: parseTag

 protected function parseTag()
 {
     $name = $this->lexer->getAdvancedToken()->value;
     $node = new Node('tag', $name);
     // Parse id, class, attributes token
     while (true) {
         switch ($this->lexer->predictToken()->type) {
             case 'id':
             case 'class':
                 $token = $this->lexer->getAdvancedToken();
                 $node->setAttribute($token->type, $token->value);
                 continue;
             case 'attributes':
                 foreach ($this->lexer->getAdvancedToken()->attributes as $name => $value) {
                     $node->setAttribute($name, $value);
                 }
                 continue;
             default:
                 break 2;
         }
     }
     // Parse text/code token
     switch ($this->lexer->predictToken()->type) {
         case 'text':
             $node->text = $this->parseText(true);
             break;
         case 'code':
             $node->code = $this->parseCode();
             break;
     }
     // Skip newlines
     while ($this->lexer->predictToken()->type === 'newline') {
         $this->lexer->getAdvancedToken();
     }
     // Tag text on newline
     if ($this->lexer->predictToken()->type === 'text') {
         if ($text = $node->text) {
             $text->addLine('');
         } else {
             $node->text = new Node('text', '');
         }
     }
     // Parse block indentation
     if ($this->lexer->predictToken()->type === 'indent') {
         $node->addChild($this->parseBlock());
     }
     return $node;
 }
开发者ID:opendena,项目名称:jade.php,代码行数:48,代码来源:Parser.php

示例4: getNode

 /**
  * Return the XML representation of this node
  *
  * @return  &xml.Node
  */
 public function getNode()
 {
     $Node = new Node($this->node_name);
     $Node->setAttribute('parent', $this->parent);
     return $Node;
 }
开发者ID:Gamepay,项目名称:xp-contrib,代码行数:11,代码来源:DiaChildnode.class.php

示例5: addFormValue

 /**
  * Add a child to the formvalues node. The XML representation
  * is probably best shown with a couple of examples:
  *
  * Example: a string
  * <xmp>
  *   <param name="__form" xsi:type="xsd:string">new</param>
  * </xmp>
  *
  * Example: an associative array
  * <xmp>
  *   <param name="data[domain]" xsi:type="xsd:string">thekidabc</param>
  *   <param name="data[tld]" xsi:type="xsd:string">de</param>
  * </xmp>
  *
  * Example: an object
  * <xmp>
  *   <param name="faxnumber" xsi:type="xsd:object">
  *     <pre>721</pre>
  *     <number>1234567</number>
  *     <lcode>+49</lcode>
  *   </param>
  * </xmp>     
  *
  * @param   string name name
  * @param   var val
  */
 public function addFormValue($name, $values)
 {
     if (!is_array($values)) {
         $values = array($values);
     }
     foreach ($values as $k => $val) {
         try {
             if (is_array($val)) {
                 $c = Node::fromArray($val, 'param');
             } else {
                 if (is_object($val)) {
                     $c = Node::fromObject($val, 'param');
                 } else {
                     $c = new Node('param', $val);
                 }
             }
             $c->setAttribute('name', $name . (is_int($k) ? '' : '[' . $k . ']'));
             $c->setAttribute('xsi:type', 'xsd:' . gettype($val));
         } catch (XMLFormatException $e) {
             // An XMLFormatException indicates data we have received on-wire
             // does not conform to XML rules - eg. contains characters that are
             // not allowed within XML documents. As on-wire data is beyond the
             // classes control, this must be handled to prevent application
             // breakage.
             // Passing special XML characters such as < or & will not fall into this
             // block - they'll just be converted to their counterpart XML entities.
             $c = new Node('param', NULL, array('name' => $name, 'xsi:type' => 'xsd:null', 'error' => 'formaterror'));
         }
         $this->document->formvalues->addChild($c);
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:58,代码来源:XMLScriptletResponse.class.php

示例6: parseSharp

	function parseSharp(&$token, Node &$data){
		return $data->setAttribute('id', $token);
	}
开发者ID:ray58750034,项目名称:shorp,代码行数:3,代码来源:TokenParser.php

示例7: testRunFinished

 /**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(TestSuite $suite, TestResult $result)
 {
     $coverage = xdebug_get_code_coverage();
     xdebug_stop_code_coverage();
     $results = array();
     foreach ($coverage as $fileName => $data) {
         foreach ($this->paths as $path) {
             if (substr($fileName, 0, strlen($path)) !== $path) {
                 continue;
             }
             $results[dirname($fileName)][basename($fileName)] = $data;
             break;
         }
     }
     $pathsNode = new Node('paths');
     foreach ($results as $pathName => $files) {
         $pathNode = new Node('path');
         $pathNode->setAttribute('name', $pathName);
         foreach ($files as $fileName => $data) {
             $fileNode = new Node('file');
             $fileNode->setAttribute('name', $fileName);
             $num = 1;
             $handle = fopen($pathName . '/' . $fileName, 'r');
             while (!feof($handle)) {
                 $line = stream_get_line($handle, 1000, "\n");
                 $lineNode = new Node('line', new CData($line));
                 if (isset($data[$num])) {
                     if ($data[$num] > 0 || $data[$num] < -1) {
                         $lineNode->setAttribute('checked', 'checked');
                     } elseif ($data[$num] > -2) {
                         $lineNode->setAttribute('unchecked', 'unchecked');
                     }
                 }
                 $fileNode->addChild($lineNode);
                 ++$num;
             }
             $pathNode->addChild($fileNode);
         }
         $pathsNode->addChild($pathNode);
     }
     $now = time();
     $pathsNode->setAttribute('time', date('Y-m-d H:i:s'));
     $this->processor->setXMLBuf($pathsNode->getSource());
     $this->processor->run();
     $reportfile = 'coverage-' . date('Y-m-d-H-i-s') . '.html';
     $reportfile = 'coverage.html';
     file_put_contents($reportfile, $this->processor->output());
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:54,代码来源:CoverageListener.class.php


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