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


PHP DomDocument::loadHTMLFile方法代码示例

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


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

示例1: loadRfc

 /**
  * @param string $rfcLocation
  */
 private function loadRfc($rfcLocation, $rfcCode)
 {
     // Suppress HTML5 errors
     libxml_use_internal_errors(true);
     $this->document = new \DOMDocument();
     $this->document->loadHTMLFile($rfcLocation);
     // Turn errors back on
     libxml_use_internal_errors(false);
     $this->rfc = new Rfc();
     $this->rfc->setCode($rfcCode);
     $this->rfc->setRawContent($this->document->saveHTML());
 }
开发者ID:shakyShane,项目名称:php-rfc-digestor,代码行数:15,代码来源:RfcBuilder.php

示例2: extractFromHtml

 /**
  * Collects all translateable strings(from tags with 'trans' attribute) from html templates
  *
  * @param string $file absoulute path to file
  */
 function extractFromHtml($file)
 {
     $dom = new DomDocument();
     $dom->loadHTMLFile($file);
     $xpath = new DomXPath($dom);
     $nodes = $xpath->query("//*[@trans]");
     foreach ($nodes as $i => $node) {
         //            $info = "<{$node->tagName}> at $file";
         $info = "";
         if ($node->hasAttribute('context')) {
             $info = 'Context: ' . $node->getAttribute('context') . '.  ' . $info;
         }
         if ($node->hasAttribute('placeholder')) {
             $this->addTranslationStr($node->getAttribute('placeholder'), $info);
         }
         if ($node->hasAttribute('title')) {
             $this->addTranslationStr($node->getAttribute('title'), $info);
         }
         if ($node->hasAttribute('data-intro')) {
             $this->addTranslationStr($node->getAttribute('data-intro'), $info);
         }
         if ($node->nodeValue != '' && $node->getAttribute('trans') != 'attr-only') {
             $this->addTranslationStr($node->nodeValue, $info);
         }
     }
 }
开发者ID:arman1823,项目名称:asasasaaa,代码行数:31,代码来源:extract.php

示例3: user_id_from_name

 public static function user_id_from_name($user)
 {
     $url = Thingiverse::BASE_URL . "/{$user}";
     $dom = new DomDocument("1.0");
     @$dom->loadHTMLFile($url);
     // use @ to suppress parser warnings
     $xp = new DomXpath($dom);
     $rss_url = $xp->query("//link[@rel=\"alternate\"]")->item(0)->getAttribute("href");
     $parts = explode(":", $rss_url);
     return $parts[2];
 }
开发者ID:experts3d,项目名称:wp-thingiverse-embed,代码行数:11,代码来源:thingiverse.php

示例4: getTemplateFromFile

 public static function getTemplateFromFile($file)
 {
     $content = new \DomDocument();
     if ($file instanceof File) {
         $content->loadHTMLFile($file->getFileName());
     } else {
         $content->loadHTML($file);
     }
     global $renderedPage;
     $renderedPage = $content;
     return new static($renderedPage);
 }
开发者ID:smnDev,项目名称:pheeca,代码行数:12,代码来源:DomTemplate.php

示例5: list

 /**
  * Loads an HTML file
  *
  * Parse errors are stored in the global array _dompdf_warnings.
  *
  * @param string $file a filename or url to load
  */
 function load_html_file($file)
 {
     // Store parsing warnings as messages (this is to prevent output to the
     // browser if the html is ugly and the dom extension complains,
     // preventing the pdf from being streamed.)
     if (!$this->_protocol && !$this->_base_host && !$this->_base_path) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
     }
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol != "file://")) {
         throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
     }
     if ($this->_protocol == "" || $this->_protocol == "file://") {
         $realfile = dompdf_realpath($file);
         if (!$file) {
             throw new DOMPDF_Exception("File '{$file}' not found.");
         }
         if (strpos($realfile, DOMPDF_CHROOT) !== 0) {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         // Exclude dot files (e.g. .htaccess)
         if (substr(basename($realfile), 0, 1) == ".") {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         $file = $realfile;
     }
     if (!DOMPDF_ENABLE_PHP) {
         set_error_handler("record_warnings");
         $this->_xml->loadHTMLFile($file);
         restore_error_handler();
     } else {
         $this->load_html(file_get_contents($file));
     }
 }
开发者ID:rifaiaja,项目名称:orpsystem,代码行数:40,代码来源:dompdf.cls.php

示例6: onFullTextSearchClick

 public function onFullTextSearchClick()
 {
     if (!$this->manual) {
         // TODO: One might think aobut using an external browser or the online docs...
         $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'GtkHTML needed');
         $dialog->set_markup('For doing full text searches GtkHTML support is required in your PHP configuration.');
         $dialog->run();
         $dialog->destroy();
         return;
     }
     $input = trim($this->glade->get_widget('searchentry')->get_text());
     if (strlen($input) == 0) {
         $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'No input');
         $dialog->set_markup('No search term entered');
         $dialog->run();
         $dialog->destroy();
         return;
     }
     $results = $this->manual->searchFulltext($input);
     $store = new \GtkTreeStore(\GObject::TYPE_STRING, \GObject::TYPE_PHP_VALUE);
     foreach ($results as $title => $found) {
         $man_container = $store->append(null, array($title, null));
         $basenamelen = strlen('phar://' . $found->getArchiveFileName());
         echo 'phar://' . $found->getArchiveFileName(), "\n";
         foreach ($found as $item) {
             /** @var $item \SplFileObject */
             $doc = \DomDocument::loadHTMLFile($item->getPathname());
             $caption = $doc->getElementsByTagName('title')->item(0)->firstChild->wholeText;
             $store->append($man_container, array($caption, $item));
         }
     }
     $tree = $this->glade->get_widget('searchtreeview');
     $tree->set_model($store);
     $tree->get_selection()->connect('changed', array($this->mainWindow, 'onSearchResultClick'));
     /* TODO: Move to view  */
     $cell_renderer = new \GtkCellRendererText();
     $colExt = new \GtkTreeViewColumn('', $cell_renderer, 'text', 0);
     $tree->append_column($colExt);
 }
开发者ID:johannes,项目名称:php-explorer,代码行数:39,代码来源:MainWindowController.php

示例7: _getHotelPages

 /**
  * 获取酒店总页数
  * @return int $pages 总页数
  */
 private function _getHotelPages()
 {
     $dom = new DomDocument();
     @$dom->loadHTMLFile($this->hotelUrl);
     $page_info = $dom->getElementById("page_info");
     if (gettype($page_info) != "object") {
         return 0;
     }
     $div = $page_info->getElementsByTagName('div')->item(0);
     $a = $div->getElementsByTagName('a');
     $numOfa = $a->length;
     $pages = (int) $a->item($numOfa - 1)->nodeValue;
     return $pages;
 }
开发者ID:starcao,项目名称:ci,代码行数:18,代码来源:hotel.php

示例8: updateGoogleCodeIndexes

function updateGoogleCodeIndexes($update = false)
{
    $local_file = basename($_SERVER['PHP_SELF']) == basename(__FILE__);
    if ($local_file) {
        $update = true;
    }
    $localFileName = 'indexes.xml';
    // check each 30 minutes
    if (!$update && file_exists($localFileName) && time() - filemtime($localFileName) < 60 * 30) {
        return;
    }
    if ($local_file) {
        echo '<h1>File update : </h1> <br>';
    }
    $dom = new DomDocument();
    $output = new DOMDocument();
    $output->formatOutput = true;
    $outputIndexes = $output->createElement("osmand_regions");
    $outputIndexes->setAttribute('mapversion', '1');
    $output->appendChild($outputIndexes);
    $st = 0;
    $num = 200;
    $count = 0;
    $mapNodes = array();
    /// 1. dlownload indexes  from googlecode
    while ($st != -1) {
        $dom->loadHTMLFile("http://code.google.com/p/osmand/downloads/list?num=" . $num . "&start=" . $st . "&colspec=Filename+Summary+Uploaded+Size");
        $count++;
        $xpath = new DOMXpath($dom);
        $xpathI = new DOMXpath($dom);
        $res = $xpath->query('//td[contains(@class,"col_0")]');
        if ($res && $res->length > 0) {
            foreach ($res as $node) {
                $indexName = trim($node->nodeValue);
                $s = $xpathI->query('td[contains(@class,"col_1")]/a[1]', $node->parentNode);
                if (!$s || $s->length == 0) {
                    continue;
                }
                $description = $s->item(0)->nodeValue;
                $i = strpos($description, "{");
                if (!$i) {
                    continue;
                }
                $i1 = strpos($description, ":", $i);
                $i2 = stripos($description, "mb", $i1);
                if (!$i2) {
                    $i2 = strpos($description, "}", $i1);
                }
                $date = trim(substr($description, $i + 1, $i1 - $i - 1));
                $size = trim(substr($description, $i1 + 1, $i2 - $i1 - 1));
                $description = trim(substr($description, 0, $i));
                if ($local_file) {
                    echo $indexName . '   ' . $date . '  ' . $size . ' <br>';
                }
                if (strpos($indexName, "voice.zip") || strpos($indexName, ".obf")) {
                    $ipart = strpos($indexName, "zip-");
                    $part = 1;
                    $base = $indexName;
                    if ($ipart) {
                        $part = (int) substr($indexName, $ipart + 4);
                        $base = substr($indexName, 0, $ipart + 3);
                        if (isset($mapNodes[$base])) {
                            $out = $mapNodes[$base];
                        } else {
                            $out = $output->createElement("multiregion");
                            $out->setAttribute("parts", $part);
                            $mapNodes[$base] = $out;
                            $out->setAttribute("date", $date);
                            $out->setAttribute("size", $size);
                            $out->setAttribute("name", $base);
                            $out->setAttribute("description", $description);
                            $outputIndexes->appendChild($out);
                        }
                        if ((int) $out->getAttribute("parts") < $part) {
                            $out->setAttribute("parts", $part);
                        }
                    } else {
                        $out = $output->createElement("region");
                        $out->setAttribute("date", $date);
                        $out->setAttribute("size", $size);
                        $out->setAttribute("name", $indexName);
                        $out->setAttribute("description", $description);
                        $outputIndexes->appendChild($out);
                        $mapNodes[$indexName] = $out;
                    }
                }
            }
            $st += $num;
        } else {
            $st = -1;
        }
    }
    /// 2. append local indexes
    // Open a known directory, and proceed to read its contents
    loadIndexesFromDir($output, $outputIndexes, 'indexes/', 'region', $mapNodes);
    loadIndexesFromDir($output, $outputIndexes, 'road-indexes/', 'road_region');
    $output->save($localFileName);
}
开发者ID:njethanandani,项目名称:Osmand,代码行数:98,代码来源:update_indexes.php

示例9: die

<?php

$result = 0;
passthru('cd ' . __DIR__ . ' && phpdoc --force', $result);
if ($result !== 0) {
    die("phpdoc command not found.");
}
libxml_use_internal_errors(true);
$dom = new DomDocument();
$dom->loadHTMLFile("./docs/index.html");
$xpath = new DomXpath($dom);
// Remove "Global" namespace
$result = $xpath->query('//li/a[@href="namespaces/default.html"]');
if ($result->length > 0) {
    $node = $result->item(0);
    $node->parentNode->parentNode->removeChild($node->parentNode);
}
// Remove Packages
$result = $xpath->query('//div[@class="well"][2]');
if ($result->length > 0) {
    $node = $result->item(0);
    $node->parentNode->removeChild($node);
}
$dom->saveHTMLFile('./docs/index.html');
开发者ID:felorodri,项目名称:RiakPHP_FunctionQueryLanguage,代码行数:24,代码来源:generate-docs.php

示例10: DomDocument

 function load_stream_from_made_url()
 {
     $dom = new DomDocument("1.0");
     @$dom->loadHTMLFile($this->url);
     // use @ to suppress parser warnings
     // FIXME: check for parse error. set some kind of thing status!
     $this->parse_thing_mades_from_html_dom($dom);
 }
开发者ID:experts3d,项目名称:wp-thingiverse-embed,代码行数:8,代码来源:thingiverse_stream.php

示例11: DomDocument

<?php

$dom = new DomDocument();
/* load HTML document (if it is not valid) */
@$dom->loadHTMLFile("http://" . $_SERVER['SERVER_ADDR'] . dirname($_SERVER['PHP_SELF']) . '/1');
$xp = new DomXpath($dom);
/* use XPath to get the title of the */
$res = $xp->query("//title/text()");
echo $res->item(0)->nodeValue;
开发者ID:SandyS1,项目名称:presentations,代码行数:9,代码来源:dom_html.php

示例12: DomDocument

/* Use internal libxml errors -- turn on in production, off for debugging */
libxml_use_internal_errors(false);
/* Createa a new DomDocument object */
$dom = new DomDocument();
// Load the active tournament
/* Load the HTML */
// NOTE: need to put the correct URL for the competition here.
// PERHAPS?: $dom->loadHTMLFile("http://www2.usfirst.org/2014comp/Events/NJCLI/matchresults.html");
//	$dom->loadHTMLFile("http://www2.usfirst.org/2014comp/Events/NJFLA/matchresults.html");		// 2014
// NOTE: Set OUR tournament ID here.
$tournament_id = "MTO";
// NOTE: Change FIRST's event id in this URL to select a different tournament.
$url = "http://frc-events.firstinspires.org/2016/NJFLA/qualifications";
// 2016
//	$url = "http://frc-events.usfirst.org/2015/GALILEO/qualifications";					// 2015
$dom->loadHTMLFile($url);
/* Create a new XPath object */
$xpath = new DomXPath($dom);
/* Query all <td> nodes containing specified class name */
$nodes = $xpath->query("//table[@class='table table-striped table-hover table-bordered table-condensed text-center']//tr[@class='hidden-xs']//td");
// 2015  UMass
//	$nodes = $xpath->query("//table[@class='clean']//tr//td");					// 2015 HH
//	$nodes = $xpath->query("//tr[@style='background-color:#FFFFFF;']//td");		// 2014
//	$nodes = $xpath->query("//td");
/* Traverse the DOMNodeList object to output each DomNode's nodeValue */
/*	foreach ($nodes as $i => $node) {
		echo "Node($i): ", $node->nodeValue, "\n";
	}
*/
/* Set HTTP response header to plain text for debugging output */
//	header("Content-type: text/plain");
开发者ID:FIRSTTeam102,项目名称:scoringapp-2016,代码行数:31,代码来源:parsematches.php

示例13: parsePredefinedClasses

 public function parsePredefinedClasses($fileLocation)
 {
     $dom = DomDocument::loadHTMLFile($this->docLocation . "/" . $fileLocation);
     $query = '//*[@class="chunklist chunklist_part"]/li/a';
     $xpath = new DOMXPath($dom);
     $entries = $xpath->query($query);
     foreach ($entries as $entry) {
         $sxml = simplexml_import_dom($entry);
         $className = (string) $sxml;
         $classLocation = (string) $sxml['href'];
         $this->classDocs[$className] = $this->parseClassDocFile($classLocation);
     }
 }
开发者ID:mingtang,项目名称:phpcomplete-extended,代码行数:13,代码来源:CorePHPDocParser.php

示例14: process_list

<?php

require '../lib/convert.php';
require '../lib/osm-writer.php';
$dom = new DomDocument();
//@$dom->loadHTMLFile( "/tmp/{$argv[1]}.html" );
echo "Processing {$argv[1]}: ";
@$dom->loadHTMLFile("http://www.itoworld.com/product/data/osm_analysis/area?name={$argv[1]}");
echo "fetched ";
$missing = $dom->getElementByID('roadsMissingBody');
$missing = simplexml_import_dom($missing);
$result = array();
@process_list($result, $missing->table);
render_to_osm($result, "ito-fetch/{$argv[1]}.osm");
echo "written\n";
function process_list(&$result, $node)
{
    foreach ($node->tr as $row) {
        $result[] = process_way($row->td->a);
    }
    foreach ($node->i as $row) {
        process_list($result, $row);
    }
}
function process_way($node)
{
    $name = $node[0];
    $href = $node['href'];
    parse_str(preg_replace('@^map_browser\\?@', '', $href), $result);
    list($left, $top, $right, $bottom) = explode(',', $result['bbox']);
    $horizontal = ($left + $right) / 2;
开发者ID:davidsoloman,项目名称:osm-tools,代码行数:31,代码来源:fetch.php

示例15: array

<?php

$next = true;
$url = "http://www.alexa.com/topsites/countries/SE";
$sites_list = array();
$args = getopt("n:");
$number_of_sites = intval($args["n"]);
if ($number_of_sites > 500 || $number_of_sites < 0) {
    $number_of_sites = 20;
}
while ($next) {
    $doc = new DomDocument();
    @$doc->loadHTMLFile($url);
    $data = $doc->getElementById('topsites-countries');
    $my_data = $data->getElementsByTagName('div');
    $xpath = new DOMXpath($doc);
    $get_websites = $xpath->query('//span[@class="small topsites-label"]');
    foreach ($get_websites as $sites) {
        $sites_list[] = $sites->nodeValue . "\n";
    }
    $is_next = $xpath->query('//a[@class="next"]');
    if ($is_next->item(0)) {
        $url = "http://www.alexa.com" . $is_next->item(0)->getAttribute("href");
    } else {
        $next = NULL;
    }
    if (count($sites_list) >= $number_of_sites) {
        break;
    }
}
for ($i = 0; $i < $number_of_sites; $i++) {
开发者ID:ktran,项目名称:frontend,代码行数:31,代码来源:alexa.php


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