• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DOMDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: decodeGz64

 function decodeGz64()
 {
     $contentNodes = $this->xpath->query("//content");
     foreach ($contentNodes as $contentNode) {
         if ($contentNode->getAttribute("contentType") == "application/x-gzip" && $contentNode->getAttribute('contentTransferEncoding') == "base64") {
             $contentDOM = new \DOMDocument();
             $contentDOM->loadXML(gzdecode(base64_decode($contentNode->nodeValue)));
             $xmlns = "http://schemas.ogf.org/nml/2013/05/base#";
             $tagName = "Topology";
             foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $netNode) {
                 $node = $this->xml->importNode($netNode, true);
                 $contentNode->nodeValue = "";
                 $contentNode->removeAttribute("contentType");
                 $contentNode->removeAttribute('contentTransferEncoding');
                 $contentNode->appendChild($node);
             }
             $xmlns = "http://schemas.ogf.org/nsi/2014/02/discovery/nsa";
             $tagName = "nsa";
             foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $nsaNode) {
                 $node = $this->xml->importNode($nsaNode, true);
                 $contentNode->nodeValue = "";
                 $contentNode->removeAttribute("contentType");
                 $contentNode->removeAttribute('contentTransferEncoding');
                 $contentNode->appendChild($node);
             }
         }
     }
 }
开发者ID:ufrgs-hyman,项目名称:proxy-agg,代码行数:28,代码来源:NSIProxy.php


示例2: modify

    function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
    {
        $dom = $namedParameters['dom'];
        if ( $dom instanceof eZContentObjectAttribute )
        {
            $this->ObjectAttributeId = $dom->attribute( 'id' );
            $content = $dom->attribute( 'content' );
            $xmlData = $content->attribute( 'xml_data' );

            $domTree = new DOMDocument( '1.0', 'utf-8' );
            $domTree->preserveWhiteSpace = false;
            $success = $domTree->loadXML( $xmlData );

            $tocText = '';
            if ( $success )
            {
                $this->HeaderCounter = array();
                $this->LastHeaderLevel = 0;

                $rootNode = $domTree->documentElement;
                $tocText .= $this->handleSection( $rootNode );

                while ( $this->LastHeaderLevel > 0 )
                {
                    $tocText .= "</li>\n</ul>\n";
                    $this->LastHeaderLevel--;
                }
            }
        }
        $operatorValue = $tocText;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:31,代码来源:eztocoperator.php


示例3: testConvertWrongConfiguration

 /**
  * Testing converting not valid cron configuration, expect to get exception
  *
  * @expectedException \InvalidArgumentException
  */
 public function testConvertWrongConfiguration()
 {
     $xmlFile = __DIR__ . '/_files/sales_invalid.xml';
     $dom = new \DOMDocument();
     $dom->loadXML(file_get_contents($xmlFile));
     $this->_converter->convert($dom);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:ConverterTest.php


示例4: serialize

 /**
  * (non-PHPdoc)
  * @see lib/Faett/Channel/Serializer/Interfaces/Faett_Channel_Serializer_Interfaces_Serializer#serialize()
  */
 public function serialize()
 {
     try {
         // initialize a new DOM document
         $doc = new DOMDocument('1.0', 'UTF-8');
         // create new namespaced root element
         $a = $doc->createElementNS($this->_namespace, 'a');
         // add the schema to the root element
         $a->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://pear.php.net/dtd/rest.allcategories http://pear.php.net/dtd/rest.allcategories.xsd');
         // create an element for the channel's name
         $ch = $doc->createElement('ch');
         $ch->nodeValue = Mage::helper('channel')->getChannelName();
         // append the element with the channel's name to the root element
         $a->appendChild($ch);
         // load the product's attributes
         $attributes = $this->_category->getSelectOptions();
         // iterate over the channel's categories
         foreach ($attributes as $attribute) {
             $c = $doc->createElement('c');
             $c->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '/channel/index/c/' . $attribute . '/info.xml');
             $c->nodeValue = $attribute;
             // append the XLink to the root element
             $a->appendChild($c);
         }
         // append the root element to the DOM tree
         $doc->appendChild($a);
         // return the XML document
         return $doc->saveXML();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:BGCX067,项目名称:faett-channel-svn-to-git,代码行数:36,代码来源:Categories.php


示例5: getMessage

 /**
  *
  * @return string
  */
 public function getMessage()
 {
     if (empty($this->_jobTraining)) {
         return '';
     }
     $this->_dom = new DOMDocument();
     $classMessage = 'alert ';
     $divFluid = $this->_dom->createElement('div');
     $divMessage = $this->_dom->createElement('div');
     $divFluid->setAttribute('class', 'row-fluid');
     if ($this->_jobTraining->status != 1) {
         $classMessage .= 'alert-error';
         $iconClass = 'icon-remove-sign';
         $alertText = ' Atensaun ';
         $message = ' Job Training ' . ($this->_jobTraining->status == 2 ? 'Kansela' : 'Taka') . ' tiha ona, La bele halo Atualizasaun.';
     } else {
         $iconClass = 'icon-ok-sign';
         $classMessage .= 'alert-success';
         $alertText = '';
         $message = ' Job Training Loke, então bele halo Atualizasaun.';
     }
     $divMessage->setAttribute('class', $classMessage);
     $strong = $this->_dom->createElement('strong');
     $i = $this->_dom->createElement('i');
     $i->setAttribute('class', $iconClass);
     $strong->appendChild($i);
     $strong->appendChild($this->_dom->createTextNode($alertText));
     $divMessage->appendChild($strong);
     $divMessage->appendChild($this->_dom->createTextNode($message));
     $divFluid->appendChild($divMessage);
     $this->_dom->appendChild($divFluid);
     return $this->_dom->saveHTML();
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:37,代码来源:JobTrainingActive.php


示例6: loadDOC

function loadDOC($html)
{
    $doc = new DOMDocument('1.0', 'UTF8');
    $doc->formatOutput = false;
    @$doc->loadHTML($html, LIBXML_COMPACT | LIBXML_NOERROR | LIBXML_NOBLANKS | LIBXML_NOWARNING | LIBXML_ERR_NONE | LIBXML_NOXMLDECL | LIBXML_HTML_NODEFDTD | LIBXML_PARSEHUGE);
    return $doc;
}
开发者ID:Broutard,项目名称:MagicMirror,代码行数:7,代码来源:recipe.php


示例7: _testXPath

 function _testXPath($xpath_expression)
 {
     if (!class_exists('DOMDocument') || !class_exists('DOMXPath')) {
         if (function_exists('domxml_open_mem')) {
             $dom = domxml_open_mem($this->_response);
             if (!$dom) {
                 $this->fail('Error parsing doc');
                 return false;
             }
             var_dump($dom);
             $xpath = $dom->xpath_init();
             var_dump($xpath);
             $ctx = $dom->xpath_new_context();
             var_dump($xpath_expression);
             $result = $ctx->xpath_eval($xpath_expression);
             var_dump($result);
             $return = new stdClass();
             $return->length = count($result->nodeset);
             return $return;
         }
         $this->fail('No xpath support built in');
         return false;
     } else {
         if (extension_loaded('domxml')) {
             $this->fail('Please disable the domxml extension. Only php5 builtin domxml is supported');
             return false;
         }
     }
     $dom = new DOMDocument();
     $dom->loadHtml($this->_response);
     $xpath = new DOMXPath($dom);
     $node = $xpath->query($xpath_expression);
     return $node;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:34,代码来源:AkTestApplication.php


示例8: saveConfig

 /**
 * Save the setup data
 * @param array $dbconfig
 * @param array $preferences
 * 
 * <?xml version="1.0" encoding="UTF-8"?>
 		<shineisp>
 			<config>
 				<database>
 					<hostname>localhost</hostname>
 					<db>shineisp</db>
 					<username>shineisp</username>
 					<password>shineisp2013</password>
 				</database>
 			</config>
 		</shineisp>
 */
 public static function saveConfig($dbconfig, $version = null)
 {
     try {
         $xml = new SimpleXMLElement('<shineisp></shineisp>');
         if (!empty($version)) {
             $xml->addAttribute('version', $version);
         }
         $xml->addAttribute('setupdate', date('Ymdhis'));
         $config = $xml->addChild('config');
         // Database Configuration
         $database = $config->addChild('database');
         $database->addChild('hostname', $dbconfig->hostname);
         $database->addChild('username', $dbconfig->username);
         $database->addChild('password', $dbconfig->password);
         $database->addChild('database', $dbconfig->database);
         // Get the xml string
         $xmlstring = $xml->asXML();
         // Prettify and save the xml configuration
         $dom = new DOMDocument();
         $dom->loadXML($xmlstring);
         $dom->formatOutput = true;
         $dom->saveXML();
         // Save the config xml file
         if (@$dom->save(APPLICATION_PATH . "/configs/config.xml")) {
             Shineisp_Commons_Utilities::log("Update ShineISP config xml file");
             return true;
         } else {
             throw new Exception("Error on saving the xml file in " . APPLICATION_PATH . "/configs/config.xml <br/>Please check the folder permissions");
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return false;
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:51,代码来源:Settings.php


示例9: excludeContentByClass

 /**
  * Exclude some html parts by class inside content wrapped with TYPO3SEARCH_begin and TYPO3SEARCH_end
  * markers.
  *
  * @param string $indexableContent HTML markup
  * @return string HTML
  */
 public function excludeContentByClass($indexableContent)
 {
     if (empty(trim($indexableContent))) {
         return html_entity_decode($indexableContent);
     }
     $excludeClasses = $this->getConfiguration()->getIndexQueuePagesExcludeContentByClassArray();
     if (count($excludeClasses) === 0) {
         return html_entity_decode($indexableContent);
     }
     $isInContent = Util::containsOneOfTheStrings($indexableContent, $excludeClasses);
     if (!$isInContent) {
         return html_entity_decode($indexableContent);
     }
     $doc = new \DOMDocument('1.0', 'UTF-8');
     libxml_use_internal_errors(true);
     $doc->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . $indexableContent);
     $xpath = new \DOMXPath($doc);
     foreach ($excludeClasses as $excludePart) {
         $elements = $xpath->query("//*[contains(@class,'" . $excludePart . "')]");
         if (count($elements) == 0) {
             continue;
         }
         foreach ($elements as $element) {
             $element->parentNode->removeChild($element);
         }
     }
     $html = $doc->saveHTML($doc->documentElement->parentNode);
     // remove XML-Preamble, newlines and doctype
     $html = preg_replace('/(<\\?xml[^>]+\\?>|\\r?\\n|<!DOCTYPE.+?>)/imS', '', $html);
     $html = str_replace(array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $html);
     return $html;
 }
开发者ID:sitegeist,项目名称:ext-solr,代码行数:39,代码来源:Typo3PageContentExtractor.php


示例10: parseResults

 private function parseResults($html)
 {
     $dom = new DOMDocument();
     $dom->loadHTML($html);
     $xpath = new DOMXpath($dom);
     $elements = $xpath->query('//*[@id="middenkolom"]/div/table/tbody/tr');
     $results = array();
     if (!is_null($elements)) {
         foreach ($elements as $element) {
             // Get image
             foreach ($xpath->query('td[1]/a/img', $element) as $image) {
                 $imageUrl = 'http://www.nedgame.nl' . $image->getAttribute('src');
             }
             // Get link & title
             foreach ($xpath->query('td[2]/a', $element) as $link) {
                 $url = $link->getAttribute('href');
                 $title = $link->nodeValue;
             }
             // Get price
             foreach ($xpath->query('td[3]/div/div[4]', $element) as $prices) {
                 preg_match('/([0-9,\\-]+)/', $prices->nodeValue, $matches);
                 $price = $matches[0];
             }
             // Get platform
             foreach ($xpath->query('td[2]/span', $element) as $details) {
                 preg_match('/Platform: (.*)Type:/', $details->nodeValue, $matches);
                 $platform = $matches[1];
             }
             $results[] = array('title' => $title, 'url' => $url, 'img' => $imageUrl, 'platform' => $platform, 'price' => $price);
         }
         return $results;
     }
 }
开发者ID:mrpapercut,项目名称:gameshopsnl,代码行数:33,代码来源:Nedgame.class.php


示例11: launch

 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     // Retrieve the record from the index
     if (!($record = $this->db->getRecord($_GET['id']))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     // Send basic information to the template.
     $interface->setPageTitle(isset($record['heading']) ? $record['heading'] : 'Heading unavailable.');
     $interface->assign('record', $record);
     // Load MARC data
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if (!$marcRecord) {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record'));
     }
     $xml = trim($marcRecord->toXML());
     // Transform MARCXML
     $style = new DOMDocument();
     $style->load('services/Record/xsl/record-marc.xsl');
     $xsl = new XSLTProcessor();
     $xsl->importStyleSheet($style);
     $doc = new DOMDocument();
     if ($doc->loadXML($xml)) {
         $html = $xsl->transformToXML($doc);
         $interface->assign('details', $html);
     }
     // Assign the ID of the last search so the user can return to it.
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     // Display Page
     $interface->setTemplate('record.tpl');
     $interface->display('layout.tpl');
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:39,代码来源:Record.php


示例12: show

 function show()
 {
     $channel_id = $this->input['channel_id'];
     if (!$channel_id) {
         $this->errorOutput('该频道不存在或者已被删除');
     }
     $dates = $this->input['dates'];
     if (!$dates) {
         $this->errorOutput('这一天不存在节目');
     }
     $sql = "select * from " . DB_PREFIX . "program where channel_id=" . $channel_id . " AND dates='" . $dates . "' ORDER BY start_time ASC ";
     $q = $this->db->query($sql);
     header('Content-Type: text/xml; charset=UTF-8');
     $dom = new DOMDocument('1.0', 'utf-8');
     $program = $dom->createElement('program');
     while ($row = $this->db->fetch_array($q)) {
         $item = $dom->createElement('item');
         $item->setAttribute('name', urldecode($row['theme']));
         $item->setAttribute('startTime', $row['start_time'] * 1000);
         $item->setAttribute('duration', $row['toff'] * 1000);
         $program->appendChild($item);
     }
     $dom->appendChild($program);
     echo $dom->saveXml();
 }
开发者ID:h3len,项目名称:Project,代码行数:25,代码来源:program_xml.php


示例13: invokeGetOrder

 function invokeGetOrder(MarketplaceWebServiceOrders_Interface $service, $request)
 {
     try {
         $response = $service->GetOrder($request);
         $dom = new DOMDocument();
         $dom->loadXML($response->toXML());
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         $data = $dom->saveXML();
         $xml = simplexml_load_string($data);
         if (empty($xml->GetOrderResult->Orders)) {
             return false;
         } else {
             //$xml->GetOrderResult->Orders
             return true;
         }
     } catch (MarketplaceWebServiceOrders_Exception $ex) {
         $message = 'MWS Order API : Caught Exception : ' . $ex->getMessage() . "\n";
         $message .= "Response Status Code: " . $ex->getStatusCode() . "\n";
         $message .= "Error Code: " . $ex->getErrorCode() . "\n";
         $message .= "Error Type: " . $ex->getErrorType() . "\n";
         $param['message'] = $message;
         $this->generate_log($param);
     }
 }
开发者ID:ankkal,项目名称:SPN_project,代码行数:25,代码来源:GetOrder.php


示例14: googleArray

 /**
  * Returns array, containing detailed results for any Google search.
  *
  * @access       private
  * @param        string        $query      String, containing the search query.
  * @param        string        $tld        String, containing the desired Google top level domain.
  * @return       array                     Returns array, containing the keys 'URL', 'Title' and 'Description'.
  */
 public static function googleArray($query)
 {
     $result = array();
     $pages = 1;
     $delay = 0;
     for ($start = 0; $start < $pages; $start++) {
         $url = 'http://www.google.' . GOOGLE_TLD . '/custom?q=' . $query . '&filter=0' . '&num=100' . ($start == 0 ? '' : '&start=' . $start . '00');
         $str = SEOstats::cURL($url);
         if (preg_match("#answer=86640#i", $str)) {
             $e = 'Please read: http://www.google.com/support/websearch/' . 'bin/answer.py?&answer=86640&hl=en';
             throw new SEOstatsException($e);
         } else {
             $html = new DOMDocument();
             @$html->loadHtml($str);
             $xpath = new DOMXPath($html);
             $links = $xpath->query("//div[@class='g']//a");
             $descs = $xpath->query("//td[@class='j']//div[@class='std']");
             $i = 0;
             foreach ($links as $link) {
                 if (!preg_match('#cache#si', $link->textContent) && !preg_match('#similar#si', $link->textContent)) {
                     $result[] = array('url' => $link->getAttribute('href'), 'title' => utf8_decode($link->textContent), 'descr' => utf8_decode($descs->item($i)->textContent));
                     $i++;
                 }
             }
             if (preg_match('#<div id="nn"><\\/div>#i', $str) || preg_match('#<div id=nn><\\/div>#i', $str)) {
                 $pages += 1;
                 $delay += 200000;
                 usleep($delay);
             } else {
                 $pages -= 1;
             }
         }
     }
     return $result;
 }
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:43,代码来源:seostats.google.php


示例15: process

 /**
  * Обрабатывает данные.
  * @param string $data XML-строка
  */
 public function process($data)
 {
     $errorHandler = new \WebConstructionSet\Xml\LibxmlErrorHandler();
     $xml = new \DOMDocument();
     if (!$xml->loadXML($data)) {
         throw new \ErrorException('Document parse failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
     }
     $xsl = new \DOMDocument();
     if ($this->xslString) {
         if (!$xsl->loadXML($this->xslString)) {
             throw new \ErrorException('XSL stylesheet load/parse failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
         }
     } else {
         $xslPath = $this->getXslStylesheetPath($xml);
         if (!$xslPath) {
             throw new \ErrorException('XSL stylesheet path is not found.', null, null, __FILE__, __LINE__);
         }
         if (!$xsl->load($xslPath)) {
             throw new \ErrorException('XSL stylesheet load/parse failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
         }
     }
     $xslt = new \XSLTProcessor();
     if (!$xslt->importStylesheet($xsl)) {
         throw new \ErrorException('Import XSL stylesheet failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
     }
     $this->resultDoc = $xslt->transformToDoc($xml);
     if (!$this->resultDoc) {
         throw new \ErrorException('XSLT transform failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
     }
     // no return
 }
开发者ID:roman-rybalko,项目名称:wcs,代码行数:35,代码来源:xslt.php


示例16: testValidateSchema

 /**
  * @dataProvider dataValidateSchemaFiles
  * @param string $file
  */
 public function testValidateSchema($file)
 {
     $found = false;
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->load($file);
     $dbalElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
     if ($dbalElements->length) {
         $dbalDom = new \DOMDocument('1.0', 'UTF-8');
         $dbalNode = $dbalDom->importNode($dbalElements->item(0));
         $dbalDom->appendChild($dbalNode);
         $ret = $dbalDom->schemaValidate(__DIR__ . "/../../Resources/config/schema/doctrine-1.0.xsd");
         $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
         $found = true;
     }
     $ormElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
     if ($ormElements->length) {
         $ormDom = new \DOMDocument('1.0', 'UTF-8');
         $ormNode = $ormDom->importNode($ormElements->item(0));
         $ormDom->appendChild($ormNode);
         $ret = $ormDom->schemaValidate(__DIR__ . "/../../Resources/config/schema/doctrine-1.0.xsd");
         $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
         $found = true;
     }
     $this->assertTrue($found, "Neither <doctrine:orm> nor <doctrine:dbal> elements found in given XML. Are namespaces configured correctly?");
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:29,代码来源:XMLSchemaTest.php


示例17: parseResinImprFile

function parseResinImprFile($file_path)
{
    global $hostDict;
    $doc = new DOMDocument();
    @$doc->loadHTMLFile($file_path);
    $query = "//table[1]/tr[@class != 'first']/td[position() < 3]";
    $xpath = new DOMXPath($doc);
    $entries = $xpath->query($query);
    $index = 0;
    $key = "";
    $value = "";
    foreach ($entries as $entry) {
        if ($index % 2 == 0) {
            $key = $entry->nodeValue;
        } else {
            $value = $entry->nodeValue;
        }
        if ($index != 0 and $index % 2 == 1) {
            if ($key == "AD_EXCHANGE.bidResult") {
                # 还不能区分bid 和 bidResult, 所以加到一起
                $key = "AD_EXCHANGE.bid";
            }
            if (array_key_exists($key, $hostDict) && !in_array($value, $hostDict[$key])) {
                array_push($hostDict[$key], $value);
            }
        }
        $index++;
    }
}
开发者ID:sleepyycat,项目名称:WebFramework,代码行数:29,代码来源:DeployDirReader.php


示例18: testConvert

 public function testConvert()
 {
     $inputData = new \DOMDocument();
     $inputData->load(__DIR__ . '/_files/webapi.xml');
     $expectedResult = (require __DIR__ . '/_files/webapi.php');
     $this->assertEquals($expectedResult, $this->_model->convert($inputData));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:ConverterTest.php


示例19: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     // NOTE: Some version of PHPCS after 1.4.6 stopped printing a valid, empty
     // XML document to stdout in the case of no errors. If PHPCS exits with
     // error 0, just ignore output.
     if (!$err) {
         return array();
     }
     $report_dom = new DOMDocument();
     $ok = @$report_dom->loadXML($stdout);
     if (!$ok) {
         return false;
     }
     $files = $report_dom->getElementsByTagName('file');
     $messages = array();
     foreach ($files as $file) {
         foreach ($file->childNodes as $child) {
             if (!$child instanceof DOMElement) {
                 continue;
             }
             if ($child->tagName == 'error') {
                 $prefix = 'E';
             } else {
                 $prefix = 'W';
             }
             $source = $child->getAttribute('source');
             $code = 'PHPCS.' . $prefix . '.' . $source;
             $message = id(new ArcanistLintMessage())->setPath($path)->setName($source)->setLine($child->getAttribute('line'))->setChar($child->getAttribute('column'))->setCode($code)->setDescription($child->nodeValue)->setSeverity($this->getLintMessageSeverity($code));
             $messages[] = $message;
         }
     }
     return $messages;
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:33,代码来源:ArcanistPhpcsLinter.php


示例20: testSerialize

 /**
  * @todo Implement testSerialize().
  */
 public function testSerialize()
 {
     $dom = new DOMDocument();
     $dom->appendChild($dom->createElement('xml'));
     $this->object->serialize('test', $dom->documentElement);
     self::assertXmlStringEqualsXmlString('<xml>test</xml>', $dom->saveXml());
 }
开发者ID:kandy,项目名称:system,代码行数:10,代码来源:NativeTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DOMElement类代码示例发布时间:2022-05-23
下一篇:
PHP DOM类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap