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


PHP DomDocument::loadHtmlFile方法代码示例

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


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

示例1: metascore

 public function metascore($type = "game", $name, $platform = NULL)
 {
     if (!$name) {
         throw new Exception("No parameters.");
     }
     $name = self::stripUrl($name);
     if ($platform) {
         $platform = self::stripUrl($platform);
     }
     $dom = new DomDocument();
     if ($type != ("movie" || "tv")) {
         $dom->loadHtmlFile("http://www.metacritic.com/{$type}/{$platform}/{$name}/");
         //replace this with Metacritics JSON search
     } else {
         $dom->loadHtmlFile("http://www.metacritic.com/{$type}/{$name}/");
         //replace this with Metacritics JSON search
     }
     $xpath = new DOMXpath($dom);
     $nodes = $xpath->evaluate("//span[@property='v:average']");
     if ($nodes) {
         return $nodes->item(0)->nodeValue;
     } else {
         throw new Exception("Could not find Metascore.");
     }
 }
开发者ID:OlegKrasnov,项目名称:Metacritic-PHP-API,代码行数:25,代码来源:MetacriticApi.php

示例2: key

            			$okres =false;
            			$kraj = false;
            			$obyvatelov = 0;
            			
            			if(isset($name2okresakraj[$name])){
            				$okres = key($name2okresakraj[$name]);
            				$kraj = key($name2okresakraj[$name][$okres]);
            				$obyvatelov = reset($name2okresakraj[$name][$okres]);
            			}/**/
        }
        // psc[psc][clearobec]
    }
}
// spracovanie kosic
$ke = array();
if ($dom = @DomDocument::loadHtmlFile("kosice-psc-na-mestsku-cast.htm")) {
    $xpath = new DomXpath($dom);
    $i = 0;
    foreach ($xpath->query("//table[@id='maintable']/tr") as $row) {
        $i++;
        if ($i == 1) {
            continue;
        }
        $cast = $xpath->query("td[2]", $row)->item(0)->nodeValue;
        $name = Texts::clear("kosice-" . $cast);
        $psc = str_replace(" ", "", $xpath->query("td[3]", $row)->item(0)->nodeValue);
        if (isset($name2okresakraj[$name])) {
            $okres = key($name2okresakraj[$name]);
            $kraj = key($name2okresakraj[$name][$okres]);
            $obyvatelov = reset($name2okresakraj[$name][$okres]);
            @($pscdata[$psc][$name][$okres][$kraj] = $obyvatelov);
开发者ID:pavolzibrita,项目名称:volby-zo-zahranicia,代码行数:31,代码来源:spracuj.php

示例3: DomXpath

if ($dom = @DomDocument::loadHtmlFile("ulice-ba.html")) {
    $xpath = new DomXpath($dom);
    $i = 0;
    foreach ($xpath->query("//table/tbody/tr") as $row) {
        $i++;
        //if($i == 1) continue;
        if (!$xpath->query("td[4]", $row)->item(0)) {
            continue;
        }
        $cast = $xpath->query("td[2]", $row)->item(0)->nodeValue;
        $name = Texts::clear("bratislava-" . $cast);
        $name = normalize_city_name($name);
        @$pocetulic[$name]++;
    }
}
if ($dom = @DomDocument::loadHtmlFile("ulice-ba.html")) {
    $xpath = new DomXpath($dom);
    $i = 0;
    foreach ($xpath->query("//table/tbody/tr") as $row) {
        $i++;
        //if($i == 1) continue;
        if (!$xpath->query("td[4]", $row)->item(0)) {
            continue;
        }
        $cast = $xpath->query("td[2]", $row)->item(0)->nodeValue;
        $name = Texts::clear("bratislava-" . $cast);
        $name = normalize_city_name($name);
        $psc = str_replace(" ", "", $xpath->query("td[4]", $row)->item(0)->nodeValue);
        $psc = str_replace("O", "0", $psc);
        if ($pos = strpos($psc, ",")) {
            //zober iba prve psc na tej ulici
开发者ID:marsher,项目名称:volby-zo-zahranicia,代码行数:31,代码来源:spracuj.php


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