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


PHP DOMDocument::loadHTMLFile方法代码示例

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


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

示例1: getWidget

 /**
  * The <div id="individu">
  * @return DOMNode
  */
 public function getWidget()
 {
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = true;
     $this->isConnected() ? $doc->loadHTMLFile('page/edit/individu.html') : $doc->loadHTMLFile('page/show/individu.html');
     return $doc->saveHTML();
 }
开发者ID:Rom1deTroyes,项目名称:Afpa2015,代码行数:11,代码来源:Individu.php

示例2: setUp

 public function setUp()
 {
     $this->test_options = new DefaultOptions();
     $this->test_options->set(Opt::DIR_ROOT, __DIR__ . '/../Fixures/LinkerTest');
     $this->test_dom = new \DOMDocument('1.0', 'UTF-8');
     $this->test_dom->loadHTMLFile(__DIR__ . '/../Fixures/InternalLink_1.html');
 }
开发者ID:hollodotme,项目名称:treemdown,代码行数:7,代码来源:LinkerTest.php

示例3: getWidget

 /**
  * The <div id="connexion">
  * @return DOMNode
  */
 public function getWidget()
 {
     $doc = new \DOMDocument();
     $doc->preserveWhiteSpace = true;
     $this->isConnected() ? $doc->loadHTMLFile('page/edit/connexion.html') : $doc->loadHTMLFile('page/show/connexion.html', LIBXML_HTML_NOIMPLIED);
     return $doc->saveHTML();
 }
开发者ID:Rom1deTroyes,项目名称:Afpa2015,代码行数:11,代码来源:Connexion.php

示例4: _crawl

 private function _crawl($url, $depth)
 {
     static $seen = array();
     if (empty($url)) {
         return;
     }
     if (!($url = $this->buildUrl($this->url, $url))) {
         return;
     }
     if ($depth === 0 || isset($seen[$url])) {
         return;
     }
     $seen[$url] = true;
     $dom = new DOMDocument('1.0');
     @$dom->loadHTMLFile($url);
     $this->results[] = array('url' => $url);
     $anchors = $dom->getElementsByTagName('a');
     foreach ($anchors as $element) {
         if (!($href = $this->buildUrl($url, $element->getAttribute('href')))) {
             continue;
         }
         $this->_crawl($href, $depth - 1);
     }
     return $url;
 }
开发者ID:rcalderini,项目名称:php-crawler,代码行数:25,代码来源:Crawler.class.php

示例5: get

function get()
{
    $name = $_GET["name"];
    $surname = $_GET["surname"];
    $address = $_GET["address"];
    $email = $_GET["email"];
    $password = $_GET["password1"];
    $bank = $_GET["bank"];
    $card_no = $_GET["cardNo"];
    $conn = new mysqli("localhost", "root", "fjab1991", "ip3_php_project_db");
    $query = "INSERT INTO customer(customer_name,customer_surname,customer_address,customer_email,customer_password,customer_bank,customer_card_no) VALUES('{$name}', '{$surname}', '{$address}', '{$email}', '{$password}', '{$bank}', '{$card_no}')";
    if ($name == "" || $name == null || $surname == "" || ($surname = null || $address == "" || $address == null || $email == "" || $email == null || $password == "" || $password == null || $bank == "" || $bank == null || $card_no == "" || $card_no == null)) {
        $doc = new DOMDocument();
        $doc->loadHTMLFile("NewCustomerPage.html");
        echo $doc->saveHTML();
        echo "<div align='center'>Please make sure you enter data in all fields.</div>";
    } else {
        if ($conn->connect_error) {
            die('Could not connect to database!');
        } else {
            if ($conn->query($query)) {
                echo 'Account created. You may login.';
                $doc = new DOMDocument();
                $doc->loadHTMLFile("LoginPage.html");
                echo $doc->saveHTML();
            } else {
                echo $conn->error;
            }
        }
    }
}
开发者ID:EnthusedDragon,项目名称:PHP_IP3_Project,代码行数:31,代码来源:NewCustomer.php

示例6: get_heros

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/11/23
 * Time: 14:49
 */
function get_heros()
{
    $urlTarget = 'http://www.dota2.com.cn/heroes/index.htm';
    //$urlTarget = 'E:/heros.html';
    //建立Dom对象,分析HTML文件;
    $htmDoc = new DOMDocument();
    $htmDoc->loadHTMLFile($urlTarget);
    //获取英雄列表
    $hero_uls = $htmDoc->getElementsByTagName("ul");
    //echo $ul_count=$hero_uls->length;
    //遍历各阵营
    $heros_url = array();
    foreach ($hero_uls as $hero_ul) {
        //先去除不是英雄列表的ul节点
        if ($hero_ul->getAttribute('class') == 'hero_list') {
            //获取单个英雄的li节点
            $hero_lis = $hero_ul->getElementsByTagName("li");
            //echo $hero_lis->length;
            //遍历各阵营下英雄,并去除阵营标识 力量-敏捷-智力
            foreach ($hero_lis as $hero_li) {
                //带class的为阵营标识
                if (!$hero_li->getAttribute('class')) {
                    //获取各个英雄资料的页面url
                    $heros_url[] = $hero_li->getElementsByTagName('a')->item(0)->getAttribute('href');
                }
            }
        }
    }
    return $heros_url;
}
开发者ID:RiceG,项目名称:Dota,代码行数:36,代码来源:GetHeros.php

示例7: load_simplexml_page

function load_simplexml_page($page, $type = 'url')
{
    ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
    $dom = new DOMDocument('1.0', 'UTF-8');
    $type === 'url' ? @$dom->loadHTMLFile(trim($page)) : @$dom->loadHTML($page);
    return simplexml_import_dom($dom);
}
开发者ID:rxhector,项目名称:faucet,代码行数:7,代码来源:controller.php

示例8: get_extension_name

function get_extension_name($file, $extensions)
{
    $doc_dir = dirname($file);
    $current_file = basename($file);
    $files_checked = array();
    do {
        if (isset($extensions[$current_file])) {
            return $extensions[$current_file];
        }
        $doc = new DOMDocument();
        $doc->loadHTMLFile($doc_dir . '/' . $current_file);
        $xpath = new DOMXPath($doc);
        $up_link = $xpath->query('//div[@class="up"]/a');
        if ($up_link->length == 0) {
            fwrite(STDERR, "\nCan't find up link in " . $current_file . ' started ascending from ' . $file);
            exit;
        }
        $up_href = $up_link->item(0)->getAttribute('href');
        if ($current_file == $up_href) {
            fwrite(STDERR, "\nup link traversal got stuck at " . $current_file . " started ascending from " . $file);
            exit;
        }
        $files_checked[] = $current_file;
        $current_file = $up_href;
    } while ($current_file != 'index.html');
    fwrite(STDERR, "\nNOTICE: Can't find extension name for " . $file . " files checked: " . join(", ", $files_checked));
    return '_unknow';
}
开发者ID:marceldev89,项目名称:phpcomplete.vim,代码行数:28,代码来源:tools.php

示例9: array

 function get_play_store()
 {
     $remote = array();
     $store_page = new DOMDocument();
     $internalErrors = libxml_use_internal_errors(true);
     $store_page->loadHTMLFile("https://play.google.com/store/search?q=awareframework%20plugin");
     $xpath = new DOMXpath($store_page);
     $packages_titles = $xpath->query('//a[@class="title"]/@href');
     foreach ($packages_titles as $pkgs) {
         $package_name = substr($pkgs->textContent, strrpos($pkgs->textContent, "=") + 1, strlen($pkgs->textContent));
         preg_match("/^com\\.aware\\.plugin\\..*/", $package_name, $matches, PREG_OFFSET_CAPTURE);
         if (count($matches) == 0) {
             continue;
         }
         $package_page = new DOMDocument();
         $package_page->loadHTMLFile("https://play.google.com/store/apps/details?id={$package_name}");
         $xpath = new DOMXpath($package_page);
         $icon = $xpath->query('//img[@class="cover-image"]/@src');
         $version = $xpath->query('//div[@itemprop="softwareVersion"]');
         $description = $xpath->query('//div[@itemprop="description"]');
         $pkg = array('title' => trim($pkgs->parentNode->textContent), 'package' => $package_name, 'version' => trim($version->item(0)->textContent), 'desc' => $description->item(0)->childNodes->item(1)->nodeValue, 'iconpath' => 'https:' . $icon->item(0)->value, 'first_name' => 'AWARE', 'last_name' => 'Framework', 'email' => 'aware@comag.oulu.fi');
         $remote[] = $pkg;
     }
     return $remote;
 }
开发者ID:denzilferreira,项目名称:aware-server,代码行数:25,代码来源:plugins_model.php

示例10: cep

function cep($filtro)
{
    $file = "http://www.buscacep.correios.com.br/servicos/dnec/consultaEnderecoAction.do?relaxation=" . $filtro . "&Metodo=listaLogradouro&TipoConsulta=relaxation&StartRow=1&EndRow=10";
    $doc = new DOMDocument();
    @$doc->loadHTMLFile($file);
    $elements = $doc->getElementsByTagName('table');
    echo "<br>\n\t<h4>Resultado:</h4>\n\t<table class='uk-table uk-table-hover uk-table-condensed uk-table-striped uk-text-nowrap uk-panel-box' style='font-size: 10px;padding: 2px;'>";
    if (!is_null($elements)) {
        $n = 0;
        foreach ($elements as $element) {
            $nodes = $element->childNodes;
            foreach ($nodes as $node) {
                $colunas = $node->childNodes;
                $endereco = "";
                foreach ($colunas as $coluna) {
                    $endereco = $endereco . $coluna->nodeValue;
                }
                if ($n > 0) {
                    echo "<tr onclick='selecionarcep(" . $n . ")' id='" . $n . "' class='uk-modal-close'>";
                    foreach ($colunas as $coluna) {
                        echo "<td style='max-width: 100px !important;width:auto;' class='uk-text-truncate'>" . mb_convert_encoding($coluna->nodeValue, 'ISO-8859-1', 'UTF-8') . "</td>";
                    }
                    echo "</tr>";
                }
                $n = $n + 1;
            }
        }
    }
    echo "</table>";
}
开发者ID:sergioflorencio,项目名称:toucan,代码行数:30,代码来源:correios.php

示例11: update

 public function update()
 {
     // this code is from Search the WordPress function reference
     // http://www.alfredforum.com/topic/2153-search-the-wordpress-function-reference/?p=12072
     // by keesiemeijer: http://www.alfredforum.com/user/4274-keesiemeijer/
     $base_url = 'http://codex.wordpress.org';
     $url = $base_url . '/Function_Reference/';
     // Create a new DOM Document to hold our webpage structure
     $xml = new DOMDocument();
     // Load the url's contents into the DOM (the @ supresses any errors from invalid XML)
     @$xml->loadHTMLFile($url);
     $links = array();
     $string = '';
     $tables = $xml->getElementsByTagName('table');
     //Loop through each <a> and </a> tag in the dom and add it to the link array
     foreach ($tables as $table) {
         if ($table->getAttribute('class') == 'widefat') {
             foreach ($table->getElementsByTagName('a') as $link) {
                 if ($link->getAttribute('href')) {
                     $links[] = array('url' => $base_url . $link->getAttribute('href'), 'title' => $link->nodeValue, 'description' => null);
                 }
             }
         }
     }
     $this->addResults($links);
     $this->save();
 }
开发者ID:Yerlix,项目名称:alfred-dev-doctor,代码行数:27,代码来源:WordPressParser.php

示例12: DOMDocument

 function import_horaire($date, $lign_id, $arret_id, $sens)
 {
     $page = 'http://www.reseau-stan.com/horaires/arret/index.asp?rub_code=28&laDate=' . $date . '&lheure=&laminute=&pointDep=&lign_id=' . $lign_id . '&pa_id=' . $arret_id . '&sens=' . $sens;
     $doc = new DOMDocument();
     if (!@$doc->loadHTMLFile($page)) {
         return FALSE;
     }
     $tableau = $doc->getElementsByTagName('tbody')->item(0);
     if (is_null($tableau)) {
         return FALSE;
     }
     $colonne = $tableau->getElementsByTagName('tr')->item(0);
     if (is_null($colonne)) {
         return FALSE;
     }
     $heures = $colonne->getElementsByTagName('td');
     if (is_null($heures)) {
         return FALSE;
     }
     $i = 5;
     foreach ($heures as $heure) {
         $heure_matche = $doc->saveHTML($heure);
         preg_match_all('/<div style=\\"background-color: #;\\">([0-9]+)<span class=\\"hidden\\">/', $heure_matche, $matches);
         $horaire[$i] = $matches[1];
         //var_dump($horaire[$i]);
         $i++;
     }
     return $horaire;
 }
开发者ID:Aigleblanc,项目名称:mapstan-gtfs,代码行数:29,代码来源:import_sitestan.php

示例13: openGame

 public function openGame($idx)
 {
     $file = $this->games[$idx]['name'];
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = true;
     $doc->formatOutput = true;
     // modify state
     $libxml_previous_state = libxml_use_internal_errors(true);
     // parse
     $doc->loadHTMLFile("Games/" . $file);
     // Usuwanie scriptow - bład z tagamiw scripcie
     $domNodeList = $doc->getElementsByTagname('script');
     $domElemsToRemove = array();
     foreach ($domNodeList as $domElement) {
         $domElemsToRemove[] = $domElement;
     }
     foreach ($domElemsToRemove as $domElement) {
         $domElement->parentNode->removeChild($domElement);
     }
     $xpath = new DomXpath($doc);
     // traverse all results
     foreach ($xpath->query('//div[@tiddler]') as $tid) {
         if ($tid->getAttribute('tiddler') != 'checkvars') {
             $this->tiddlers[$tid->getAttribute('tiddler')] = $tid->nodeValue;
         }
     }
     // handle errors
     libxml_clear_errors();
     // restore
     libxml_use_internal_errors($libxml_previous_state);
 }
开发者ID:Largin,项目名称:TwineDoodler,代码行数:31,代码来源:games.php

示例14: extract_class_signatures

function extract_class_signatures($files, $extensions)
{
    $class_signatures = array();
    $interface_signatures = array();
    foreach ($files as $file) {
        $doc = new DOMDocument();
        $doc->loadHTMLFile($file);
        $xpath = new DOMXpath($doc);
        list($classname, $is_interface) = extract_class_name($xpath, $file);
        if (empty($classname)) {
            // no usual class synopsis found inside the file, just skip this class
            continue;
        }
        $fields = extract_class_fields($xpath, $classname, $file);
        $methods = extract_class_methods($xpath, $classname, $file);
        $extension_name = get_extension_name($file, $extensions);
        if (!isset($class_signatures[$extension_name][$classname])) {
            if ($is_interface) {
                if (!isset($interface_signatures[$extension_name])) {
                    $interface_signatures[$extension_name] = array();
                }
                $interface_signatures[$extension_name][$classname] = array('constants' => $fields['constants'], 'properties' => $fields['properties'], 'static_properties' => $fields['static_properties'], 'methods' => $methods['methods'], 'static_methods' => $methods['static_methods']);
            } else {
                if (!isset($class_signatures[$extension_name])) {
                    $class_signatures[$extension_name] = array();
                }
                $class_signatures[$extension_name][$classname] = array('constants' => $fields['constants'], 'properties' => $fields['properties'], 'static_properties' => $fields['static_properties'], 'methods' => $methods['methods'], 'static_methods' => $methods['static_methods']);
            }
        } else {
            // there are some duplicate class names in extensions, use only the first one
        }
    }
    return array($class_signatures, $interface_signatures);
}
开发者ID:marceldev89,项目名称:phpcomplete.vim,代码行数:34,代码来源:classes.php

示例15: score_html

 public function score_html($path)
 {
     /*
     REQUIREMENT #1: Accept HTML Content Input
     REQUIREMENT #2: Accept unique id for HTML Content to score (filename prefix) - THIS IS DONE IN THE DATABASE CLASS->insert_score METHOD
     REQUIREMENT #3: Score HTML content using the scoring guide
     REQUIREMENT #4: Save results to a MySQL database
     */
     $doc = new \DOMDocument();
     @$doc->loadHTMLFile($path);
     $rules = $this->DB->get_rules();
     $score = 0;
     foreach ($rules as $rule) {
         $result = $doc->getElementsByTagName($rule->tag_name);
         $instances = $result->length;
         for ($i = 0; $i < $instances; $i++) {
             $score += (int) $rule->points;
         }
     }
     $filename = basename($path);
     if (!empty($this->DB->get_scores_by_id($filename))) {
         $this->DB->update_score($filename, $score);
     } else {
         $this->DB->insert_score($score, $filename);
     }
 }
开发者ID:diegocam,项目名称:Markup,代码行数:26,代码来源:HtmlReader.php


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