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


PHP DomDocument::getElementById方法代码示例

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


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

示例1: getIDNodeFromUserPage

 public function getIDNodeFromUserPage($idnode)
 {
     $html_page = new DomDocument();
     $html_page->loadHTML($this->getCachedUserPage());
     if ($html_page->getElementById($idnode)) {
         return $html_page->getElementById($idnode);
     }
     return false;
 }
开发者ID:crashfortstudios,项目名称:facepunch,代码行数:9,代码来源:Facepunch.php

示例2: getGEDTFormTokens

 private function getGEDTFormTokens()
 {
     //Extract the validation data
     libxml_use_internal_errors(true);
     //skip DOM errors
     $dom = new DomDocument();
     $dom->loadHTML($this->upload_form);
     $this->form_objects['__VIEWSTATE'] = $dom->getElementById('__VIEWSTATE')->getAttribute('value');
     $this->form_objects['__EVENTVALIDATION'] = $dom->getElementById('__EVENTVALIDATION')->getAttribute('value');
 }
开发者ID:bdereta,项目名称:gedt,代码行数:10,代码来源:DomClient.php

示例3: DomDocument

 function __construct($ch, $url)
 {
     print "Initializing hero's adventure data\n";
     curl_setopt($ch, CURLOPT_URL, $url . $this->relativeUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     $doc = new DomDocument();
     $doc->loadHTML($result);
     $adventures = $doc->getElementById('adventureListForm')->getElementsByTagName('tr');
     // The first element will be the title of the table so we have to skip it
     $firstElement = true;
     foreach ($adventures as $i => $adv) {
         if ($firstElement) {
             $firstElement = false;
         } else {
             $fields = array();
             // Add the link needed to go to this adventure
             if (count($adv->getElementsByTagName('a')) > 1) {
                 $fields['href'] = $adv->getElementsByTagName('a')->item(1)->getAttribute('href');
                 // Getting hidden fields
                 foreach ($adv->getElementsByTagName('input') as $j => $input) {
                     $fields[$input->getAttribute('name')] = $input->getAttribute('value');
                 }
                 $this->adventureList[trim($adv->getElementsByTagName('td')->item(2)->childNodes->item(0)->nodeValue) . ' <=> ' . $adv->getElementsByTagName('td')->item(4)->childNodes->item(1)->nodeValue] = $fields;
             } else {
                 echo "No hay aventuras. Si este mensaje se imprime mas de una vez, algo va mal";
             }
         }
     }
     asort($this->adventureList);
 }
开发者ID:pevalme,项目名称:Travian-command-line-tool,代码行数:31,代码来源:HeroAdventure.php

示例4: process

 public function process($args)
 {
     $answer = "";
     $args = trim($args);
     if (strlen($args) > 0) {
         $entrada = urlencode($args);
         $url = "https://www.google.com.mx/search?q={$entrada}&oq=200&aqs=chrome.1.69i57j69i59j69i65l2j0l2.3015j0j8&client=ubuntu-browser&sourceid=chrome&es_sm=122&ie=UTF-8";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.120 Chrome/37.0.2062.120 Safari/537.36');
         $html = curl_exec($ch);
         $web = new DomDocument();
         @$web->loadHTML($html);
         $nodos = @$web->getElementById('topstuff')->getElementsByTagName('div');
         $answer = "No pude convertir lo que me pides.";
         if ($nodos) {
             $nodos = iterator_to_array($nodos);
             if (count($nodos) === 6) {
                 $answer = utf8_decode($nodos[3]->nodeValue . " " . $nodos[4]->nodeValue);
             }
         }
     } else {
         $answer = "Ingresa una expresion.";
     }
     $this->reply($answer, $this->currentchannel, $this->nick);
 }
开发者ID:jahrmando,项目名称:botijon,代码行数:27,代码来源:convertir.php

示例5: getFollowers

function getFollowers($username){
  $x = file_get_contents("http://twitter.com/".$username);
  $doc = new DomDocument;
  @$doc->loadHTML($x);
  $ele = $doc->getElementById('follower_count');
  $innerHTML=preg_replace('/^<[^>]*>(.*)<[^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
  return $innerHTML;
}
开发者ID:JustDevZero,项目名称:Wordpress,代码行数:8,代码来源:followers.php

示例6: testToOptionArray

 public function testToOptionArray()
 {
     $this->dispatch('backend/admin/system_config/edit/section/admin');
     $dom = new DomDocument();
     $dom->loadHTML($this->getResponse()->getBody());
     $select = $dom->getElementById('admin_startup_menu_item_id');
     $this->assertNotEmpty($select, 'Startup Page select missed');
     $options = $select->getElementsByTagName('option');
     $optionsCount = $options->length;
     $this->assertGreaterThan(98, $optionsCount, 'Paucity count of menu items in the list');
     $this->assertEquals('Dashboard', $options->item(0)->nodeValue, 'First element is not Dashboard');
     $this->assertContains('Configuration', $options->item($optionsCount - 1)->nodeValue);
 }
开发者ID:rorteg,项目名称:magento2,代码行数:13,代码来源:PageTest.php

示例7: parseAllProducts

function parseAllProducts($timePoint = 0)
{
    global $productModel;
    $dom = new DomDocument('1.0', 'utf-8');
    $dom->strictErrorChecking = false;
    @$dom->loadHTML(getGuzzleContent());
    $productsParentDE = $dom->getElementById('hl');
    $productDEs = getElementsByClass($productsParentDE, 'div', 'chotot-list-row');
    $time = time();
    $products = [];
    foreach ($productDEs as $productDE) {
        $productUrlTag = $productDE->getElementsByTagName('a')->item(0);
        $productInfo = $productDE->getElementsByTagName('div')->item(0);
        $product = new stdClass();
        $thumbDEs = getElementsByClass($productDE, 'div', 'listing_thumbs_image');
        $priceDEs = getElementsByClass($productDE, 'div', 'ad-price');
        $locationDEs = getElementsByClass($productDE, 'span', 'municipality');
        $linkDEs = getElementsByClass($productDE, 'a', 'ad-subject');
        foreach ($linkDEs as $linkDE) {
            $url = $linkDE->getAttribute('href');
            $urlExpStr = explode('-', $url);
            $id = explode('.', end($urlExpStr))[0];
            $product->id = $id;
            $product->title = trim($linkDE->getAttribute('title'));
            $product->url = $url;
            $product->created_at = $time;
        }
        foreach ($thumbDEs as $thumbDE) {
            $img = $thumbDE->getElementsByTagName('img')->item(0);
            $product->thumbnail = $img->getAttribute('src');
        }
        foreach ($priceDEs as $priceDE) {
            $product->price = trim($priceDE->nodeValue);
        }
        foreach ($locationDEs as $locationDE) {
            $product->location = trim($locationDE->nodeValue);
        }
        $products[] = $product;
        $productModel->insertProduct($product);
    }
    return $productModel->getProducts($timePoint);
}
开发者ID:victoray,项目名称:ChoTot-simple-crawler,代码行数:42,代码来源:action.php

示例8: 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

示例9: _postToLoginParseHtmlForm

 private function _postToLoginParseHtmlForm($html)
 {
     $data = array();
     $dom = new DomDocument();
     @$dom->loadHTML($html);
     $loginForm = $dom->getElementById("loginForm");
     $z = $loginForm->getElementsByTagName("input");
     foreach ($z as $input) {
         $name = $input->getAttribute('name');
         $value = $input->getAttribute('value');
         $data[$name] = $value;
     }
     $data['username'] = $this->username;
     $data['password'] = $this->password;
     $data['timezone_field'] = str_replace(':', '|', date('P'));
     // ?data.put("timezone_field", new SimpleDateFormat("XXX").format(now).replace(':', '|'));
     $data['js_time'] = time() / 1000;
     // ?  data.put("js_time", String.valueOf(now.getTime() / 1000));
     return $data;
 }
开发者ID:tommydart,项目名称:skype4php,代码行数:20,代码来源:skype4php.php

示例10: array

<?php

header('Content-Type: application/json');
$channel = $_GET['channel'];
$id = $_GET['id'];
$title = '';
$view = '';
$status = '';
$object = array();
switch ($channel) {
    case 'talktv':
        $doc = new DomDocument();
        $doc->loadHTMLFile('http://talktv.vn/' . $id);
        //status
        $thediv = $doc->getElementById('stream-status-live');
        $status = trim($thediv->textContent);
        if ($status == 'Đang phát') {
            $status = 'live';
        } else {
            $status = 'offline';
        }
        //view
        $thediv = $doc->getElementById('player-viewing-count');
        $view = trim($thediv->textContent);
        //title
        $thediv = $doc->getElementById('broadcast-title');
        $title = trim($thediv->textContent);
        break;
    case 'youtube':
        $view = file_get_contents('https://www.youtube.com/live_stats?v=' . $id);
        //get view
开发者ID:bangnokia,项目名称:dota2vn-bet-group,代码行数:31,代码来源:streamstatus.php

示例11: unset

}
$display = true;
if (isset($_POST['submit'])) {
    unset($_POST['submit']);
    $user_id = "";
    if (validateUserLogin($err_msg)) {
        $conn = new dbAccess($debug);
        if (($rc = $conn->dbLoginUser($username, $password, $user_id)) == GOOD_RC) {
            // we have a valid user
            // Create new session, store the user id
            $_SESSION['user_id'] = $user_id;
            $sess_id = session_id();
            $_SESSION['sess_id'] = $sess_id;
            $dom = new DomDocument();
            $dom->validateOnParse = true;
            $el = $dom->getElementById('sess_id');
            $el->nodeValue = $sess_id;
            $uid = $dom->getElementById('user_id');
            $uid->nodeValue = $user_id;
            // Redirect to user info page
            ob_end_clean();
            header('Location: ' . $baseURL . '/dataAccess/userInfo.php');
            //http_redirect('www.google.com', true, HTTP_REDIRECT_PERM);
            exit;
        } else {
            $err_msg = $conn->errmsg;
            session_destroy();
        }
    }
    // end if valid input
}
开发者ID:katcoder,项目名称:myvistaverde,代码行数:31,代码来源:login.php

示例12: _getHotelMessage

 /**
  * 从页面抓取酒店信息
  * @param string $html html内容
  * @param int $hotelid 酒店id
  * @return mixed $data
  */
 private function _getHotelMessage($html, $hotelid)
 {
     $dom = new DomDocument();
     $searchPage = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
     @$dom->loadHTML($searchPage);
     $idhtml = $dom->getElementById($hotelid);
     if (gettype($idhtml) != "object") {
         return false;
     }
     $p = @$idhtml->firstChild->firstChild->nextSibling->firstChild->firstChild->lastChild;
     if (gettype($p) != "object") {
         return false;
     }
     $data['brief'] = @$p->lastChild->previousSibling->previousSibling->nodeValue;
     $data['address'] = @$p->firstChild->nextSibling->lastChild->attributes->item(0)->value;
     $data['tarea'] = @$p->firstChild->nextSibling->lastChild->previousSibling->previousSibling->nodeValue;
     if ($data['tarea'] == " ") {
         $data['tarea'] = @$p->firstChild->nextSibling->lastChild->previousSibling->previousSibling->previousSibling->nodeValue;
     }
     if (!$data['brief'] || !$data['address'] || !$data['tarea']) {
         return false;
     }
     return $data;
 }
开发者ID:starcao,项目名称:ci,代码行数:30,代码来源:hotel.php

示例13: DomDocument

require AT_INCLUDE_PATH . 'header.inc.php';
//
// Mauro Donadio
//
$fp = @file_get_contents($content_row['text']);
// just for AContent content
if (strstr($fp, 'AContentXX')) {
    //$fp		= str_ireplace('<head>','<MAURO>',$fp);
    //<base href="http://www.w3schools.com/images/" target="_blank" />
    // a new dom object
    $dom = new DomDocument();
    libxml_use_internal_errors(TRUE);
    // load the html into the object
    $dom->loadHTML($fp);
    libxml_use_internal_errors(FALSE);
    $doc->formatOutput = TRUE;
    //discard white space
    $dom->preserveWhiteSpace = false;
    $node = $dom->getElementById('content-text');
    // row commented because of the old version of PHP
    //$content	= $dom->saveHTML($node);
    $content = $dom->saveXML($node, LIBXML_NOEMPTYTAG);
    // overwrite the original content with the filtered one
    $savant->assign('body', stripslashes($content));
    $savant->assign('module_contents', '');
}
$savant->display('content.tmpl.php');
// --
//save last visit page.
$_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
require AT_INCLUDE_PATH . 'footer.inc.php';
开发者ID:genaromendezl,项目名称:ATutor,代码行数:31,代码来源:content.php

示例14: DomDocument

include "inc/header.inc";
$doc = new DomDocument();
// We need to validate our document before refering to the id
$doc->validateOnParse = false;
$doc->loadHtml(file_get_contents($_GET['page']));
?>
<div data-role="page" id="content" data-add-back-btn="true">

	<div data-role="header">
		<h1><?echo $_GET['title'] ?></h1>
	</div><!-- /header -->

	<div data-role="content">	
	<p>
<?

$links = $doc->getElementsByTagName("a");
foreach($links as $link) {
  $href = $link->getAttribute("href");
  $newLink = "content.php?page=" . $href;
  $link->setAttribute("href",$newLink);
}

$elemContent = $doc->getElementById('content');
$elemText = $elemContent->ownerDocument->saveXML($elemContent);
echo $elemText;
?>
	</p>
	</div><!-- /content -->
<?php 
include "inc/footer.inc";
开发者ID:n8fr8,项目名称:NYCGAMobile,代码行数:31,代码来源:content.php

示例15: errorProcessing

if (!file_exists(plotsXml)) {
    // DES plots description
    errorProcessing($ID, "InternalError00: no plots description file");
    if (file_exists(resultDir . $ID)) {
        rrmdir(resultDir . $ID);
    }
    die;
}
$dom = new DomDocument("1.0");
$dom->load(plotsXml);
chdir($resDirName . "/RES");
// Down to working directory
$i = 0;
foreach ($missions as $mission) {
    $fileS = fopen(requestList, "w");
    $missionTag = $dom->getElementById($mission);
    $params = $missionTag->getElementsByTagName('param');
    //TODO calculate deltaY from number of vars
    $yStart = 0.1;
    fwrite($fileS, $params->length . PHP_EOL);
    foreach ($params as $param) {
        $yStop = $yStart + 0.2;
        fwrite($fileS, $param->getAttribute('name') . ' 0 ' . $yStart . ' 0.95 ' . $yStop . ' 0 0 0 0' . PHP_EOL);
        $yStart += 0.2;
    }
    $startTime = strtotime($start[$i]);
    $endTime = strtotime($stop[$i]);
    $TIMEINTERVAL = timeInterval2Days($endTime - $startTime);
    $STARTTIME = startTime2Days($startTime);
    fwrite($fileS, $STARTTIME . PHP_EOL . $TIMEINTERVAL . PHP_EOL);
    fclose($fileS);
开发者ID:helio-vo,项目名称:helio,代码行数:31,代码来源:multiPlot.php


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