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


PHP DOMDocument::getElementById方法代码示例

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


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

示例1: testCorrectSetup

 public function testCorrectSetup()
 {
     $cloneable = $this->prepareValidCloneableField();
     $this->form->add($cloneable);
     $this->assertInstanceOf('\\Phalcon\\DI', $this->form->get('cloneable_field')->getDecorator()->getDI());
     $this->form->get('cloneable_field')->getDecorator()->setTemplateName('jquery');
     $domDoc = new \DOMDocument('1.0');
     $domDoc->loadHTML($this->form->get('cloneable_field')->render());
     $this->assertEquals(2, $domDoc->getElementById('cloneable_field')->getElementsByTagName('fieldset')->length);
     $this->assertEquals(4, $domDoc->getElementById('cloneable_field')->getElementsByTagName('input')->length);
     $domDoc->loadHTML($this->form->get('cloneable_field')->render(['attribute' => 'test']));
     $this->assertEquals('test', $domDoc->getElementById('cloneable_field')->attributes->getNamedItem('attribute')->value);
     $this->assertNull($this->form->get('cloneable_field')->getBaseElement('test3'));
     $this->assertInstanceOf('\\Phalcon\\Forms\\ElementInterface', $this->form->get('cloneable_field')->getBaseElement('test2'));
 }
开发者ID:vegas-cmf,项目名称:forms,代码行数:15,代码来源:CloneableTest.php

示例2: startGame

function startGame($gameID)
{
    error_reporting(0);
    $api = curl_init('http://play.textadventures.co.uk/Play.aspx?id=' . $gameID);
    curl_setopt($api, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($api, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($api, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($api, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($api);
    $dom = new DOMDocument();
    $dom->loadHTML($result);
    $viewState = $dom->getElementById('__VIEWSTATE');
    $viewStateGenerator = $dom->getElementById('__VIEWSTATEGENERATOR');
    $eventValidation = $dom->getElementById('__EVENTVALIDATION');
    $viewState = $viewState->attributes->getNamedItem('value')->nodeValue;
    $viewStateGenerator = $viewStateGenerator->attributes->getNamedItem('value')->nodeValue;
    $eventValidation = $eventValidation->attributes->getNamedItem('value')->nodeValue;
    echo '"' . $eventValidation . '"<br>';
    echo '"' . $viewState . '"<br>';
    echo '"' . $viewStateGenerator . '"<br>';
    echo '------------------<br>';
    error_reporting(-1);
    //sleep(1);
    startGame_stage2($gameID, $viewState, $viewStateGenerator, $eventValidation);
}
开发者ID:nunomcb,项目名称:yoda-hipchat,代码行数:25,代码来源:rpg.php

示例3: getDirectoryListing

function getDirectoryListing($result, $path, $cat)
{
    $path .= " > " . $cat;
    $cat = str_replace(" ", "_", $cat);
    $ch = curl_init();
    $buffer = fopen("buffer.html", "w");
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2");
    curl_setopt($ch, CURLOPT_URL, "http://ru.wikipedia.org/wiki/Категория:" . $cat);
    curl_setopt($ch, CURLOPT_FILE, $buffer);
    curl_exec($ch);
    curl_close($ch);
    fclose($buffer);
    // working with the pre-fetched page using DOMDocument
    // due to a bug (?) w/ fetching Cyrillic URLs via DOMDocument->loadHTMLFile
    $html = new DOMDocument();
    $html->loadHTMLFile("buffer.html");
    $subCats = $html->getElementById("mw-subcategories");
    if ($subCats) {
        foreach ($subCats->getElementsByTagName("a") as $s) {
            getDirectoryListing($result, $path, $s->textContent);
        }
        unset($subCats);
    }
    $pages = $html->getElementById("mw-pages");
    if ($pages) {
        foreach ($pages->getElementsByTagName("a") as $a) {
            fwrite($result, "{$path} > {$a->textContent}" . PHP_EOL);
        }
        unset($pages);
    }
}
开发者ID:ngineer,项目名称:wikiTree,代码行数:31,代码来源:newtree.php

示例4: removeToc

 /**
  * Removes the TOC (#toc) from the body
  */
 protected function removeToc()
 {
     $element = $this->dom->getElementById('toc');
     if ($element !== null) {
         $element->parentNode->removeChild($element);
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:10,代码来源:MobileFrontend2_PostParse.php

示例5: handleError

 public function handleError(\Dwoo\Exception $e)
 {
     $html = new \DOMDocument();
     $html->loadHTMLFile('lib/resources/exception.html');
     $message = $html->getElementById('message');
     $template = $html->createDocumentFragment();
     $template->appendXML($e->getMessage());
     $message->appendChild($template);
     unset($template);
     $php_version = $html->getElementById('php-version');
     $template = $html->createDocumentFragment();
     $template->appendXML(phpversion());
     $php_version->appendChild($template);
     unset($template);
     $dwoo_version = $html->getElementById('dwoo-version');
     $template = $html->createDocumentFragment();
     $template->appendXML(Core::VERSION);
     $dwoo_version->appendChild($template);
     unset($template);
     $exectime = $html->getElementById('exectime');
     $template = $html->createDocumentFragment();
     $template->appendXML(round(microtime(true) - $_SERVER['REQUEST_TIME'], 3));
     $exectime->appendChild($template);
     unset($template);
     echo $html->saveHTML();
 }
开发者ID:Keegomyneego,项目名称:cockamamei,代码行数:26,代码来源:Exception.php

示例6: getCurrentSslVoting

 /**
  * @param string $uri
  * @return string
  * @throws \Exception
  */
 protected function getCurrentSslVoting($uri, $ip = NULL)
 {
     $pathSegments = parse_url($uri);
     if ($ip === NULL) {
         if (!array_key_exists('host', $pathSegments)) {
             throw new \Exception('The Uri' . $uri . ' can´ be parsed cleanly');
         }
         $ip = gethostbyname($pathSegments['host']);
     }
     $buffer = file_get_contents('https://www.ssllabs.com/ssltest/analyze.html?d=' . urlencode($pathSegments['host']) . '&s=' . $ip);
     libxml_use_internal_errors(true);
     $domDocument = new \DOMDocument();
     $domDocument->loadHTML($buffer);
     $ratingElement = $domDocument->getElementById('rating');
     if ($ratingElement === NULL) {
         $warningBox = $domDocument->getElementById('warningBox');
         if ($warningBox !== null) {
             switch (trim($warningBox->textContent)) {
                 case 'Assessment failed: No secure protocols supported':
                 case 'Assessment failed: Unable to connect to server':
                     throw new NoSslException(trim($warningBox->textContent), $this->getSession());
                     break;
                 default:
                     throw new StillRunningException(trim($warningBox->textContent), $this->getSession());
                     break;
             }
         }
         throw new \Exception('No voting available yet');
     }
     libxml_use_internal_errors(false);
     return trim($ratingElement->childNodes->item(3)->textContent);
 }
开发者ID:kaystrobach,项目名称:behat-extension,代码行数:37,代码来源:FeatureContext.php

示例7: parse

 public function parse($html)
 {
     if (empty($html)) {
         $this->title = $this->message = 'Empty exception';
         $this->sourceFile = '';
         return false;
     }
     if (!$this->domDocument) {
         $this->domDocument = new \DOMDocument();
     }
     @$this->domDocument->loadHTML($html);
     $titleItem = $this->domDocument->getElementsByTagName("title")->item(0);
     $this->title = $titleItem ? $titleItem->textContent : 'N/A';
     try {
         $sourceFileElement = $this->domDocument->getElementById("tracy-bs-error");
         if (is_object($sourceFileElement)) {
             $sourceFileLinkNode = $sourceFileElement->getElementsByTagName("a")->item(0);
             $this->sourceFile = trim($sourceFileLinkNode->textContent);
         } else {
             $this->sourceFile = 'Unknown format of exception';
         }
         $messageNode = $this->domDocument->getElementsByTagName("p")->item(0);
         if (is_object($messageNode)) {
             $messageNode->removeChild($messageNode->lastChild);
             $this->message = trim($messageNode->textContent);
         } else {
             $this->message = 'Unable to parse';
         }
     } catch (\Exception $e) {
         $this->message = 'Unable to parse';
     }
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:32,代码来源:ExceptionParser.php

示例8: get_profile_email

function get_profile_email($url)
{
    global $g_acegi_cookie;
    global $g_session_cookie;
    global $g_delay;
    sleep($g_delay);
    // Create a stream
    // get cookie values using wget commands
    $cookie = sprintf("Cookie: ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE=%s; JSESSIONID=%s\r\n", $g_acegi_cookie, $g_session_cookie);
    $opts = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n" . $cookie));
    $context = stream_context_create($opts);
    @($html = file_get_contents($url, false, $context));
    $doc = new \DOMDocument();
    @$doc->loadHTML($html);
    $emailNode = $doc->getElementById("email1__ID__");
    $nameNode = $doc->getElementById("name1__ID__");
    $titleNode = $doc->getElementById("title1__ID__");
    $companyNode = $doc->getElementById("company1__ID__");
    if (!is_null($emailNode)) {
        $data = array();
        $data["email"] = $emailNode->nodeValue;
        $data["name"] = is_null($nameNode) ? "" : $nameNode->nodeValue;
        $data["title"] = is_null($titleNode) ? "" : $titleNode->nodeValue;
        $data["company"] = is_null($companyNode) ? "" : $companyNode->nodeValue;
        return $data;
    }
    return NULL;
}
开发者ID:rjha,项目名称:sc,代码行数:28,代码来源:curl-search.php

示例9: t

function t($xml)
{
    $dom = new DOMDocument();
    $dom->loadHTML($xml);
    $child = $dom->getElementById('x');
    $child = null;
    $child = $dom->getElementById('x');
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:getelementbyid_free.php

示例10: transform

 public function transform()
 {
     E()->getResponse()->setHeader('Content-Type', 'text/javascript; charset=utf-8');
     $component = $this->document->getElementById('result');
     if (!$component) {
         throw new SystemException('ERR_BAD_OPERATION_RESULT', SystemException::ERR_CRITICAL, $this->document->saveHTML());
     }
     return $component->nodeValue;
 }
开发者ID:energine-cmf,项目名称:energine,代码行数:9,代码来源:JSONTransformer.php

示例11: get_song

function get_song($content)
{
    //$host = 'http://zaycev.net';
    //$content = file_get_contents($url);
    $dom = new DOMDocument();
    $dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=windows-1251">' . $content);
    $link = $dom->getElementById("pages-download-button")->getAttribute('href');
    $name = $dom->getElementById("pages-download-link")->nodeValue;
    return array('name' => $name, 'link' => $link);
}
开发者ID:Ruzon,项目名称:zaycev,代码行数:10,代码来源:index.php

示例12: PegaNivelRioDoceGV

function PegaNivelRioDoceGV($url = "http://saaegoval.com.br/custom/niv_rio_vis.aspx")
{
    $html = file_get_contents($url);
    $dom = new DOMDocument('1.0');
    $dom->loadHTML($html);
    $txNivel = $dom->getElementById('txNivel');
    $txData = $dom->getElementById('txData');
    $txHora = $dom->getElementById('txHora');
    $NivelDoRioDoceGV = new StdClass();
    $NivelDoRioDoceGV->nivel = $txNivel->C14N();
    $NivelDoRioDoceGV->data = $txData->C14N();
    $NivelDoRioDoceGV->hora = $txHora->C14N();
    return $NivelDoRioDoceGV;
}
开发者ID:marcelobarbosadg87,项目名称:Nivel-Rio-Doce-GV,代码行数:14,代码来源:engine.php

示例13: findUser

 public function findUser($nick)
 {
     $options = array(CURLOPT_URL => 'http://rutracker.org/forum/profile.php?mode=viewprofile&u=' . $nick, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_USERAGENT => self::$agent, CURLOPT_COOKIEJAR => self::$cookieFile, CURLOPT_COOKIEFILE => self::$cookieFile, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10);
     $curl = curl_init();
     curl_setopt_array($curl, $options);
     $result = curl_exec($curl);
     curl_close($curl);
     $doc = new DOMDocument();
     @$doc->loadHTML($result);
     $role = $this->clean($doc->getElementById('role')->textContent);
     $totalDownloaded = $this->clean($doc->getElementById('u_down_total')->textContent);
     $totalUploaded = $this->clean($doc->getElementById('u_up_total')->textContent);
     $regDate = $this->clean($doc->getElementById('user_regdate')->textContent);
     return array('role' => $role, 'totalDownloaded' => $totalDownloaded, 'totalUploaded' => $totalUploaded, 'registerDate' => $regDate);
 }
开发者ID:makarenkoyn,项目名称:rutrackerapi,代码行数:15,代码来源:Rutracker.php

示例14: lettering

 /**
  * Our function called via Twig; it can do anything you want
  *
  * @return string
  */
 public function lettering($text = null, $class = 'chars')
 {
     if (!$text || strlen($text) === 0 || !method_exists(craft()->lettering, $class)) {
         return $text;
     }
     $dom = new LetteringDom();
     $dom->loadHTML(mb_convert_encoding('<div id="workingNode">' . $text . '</div>', 'HTML-ENTITIES', $this->encoding));
     $workingNode = $dom->getElementById('workingNode');
     $fragment = $dom->createDocumentFragment();
     foreach ($workingNode->childNodes as $node) {
         if ($node->nodeType !== 1) {
             continue;
         }
         $value = $node->nodeValue;
         $result = craft()->lettering->{$class}($value, $class);
         $node->nodeValue = '';
         $tempFragment = new LetteringDom();
         $tempFragment->loadHTML(mb_convert_encoding($result[$class], 'HTML-ENTITIES', $this->encoding));
         foreach ($tempFragment->getElementsByTagName('body')->item(0)->childNodes as $tempNode) {
             $tempNode = $node->ownerDocument->importNode($tempNode, true);
             $node->appendChild($tempNode);
         }
         $node->setAttribute('aria-label', trim(strip_tags($value)));
         $fragment->appendChild($node->cloneNode(true));
     }
     $workingNode->parentNode->replaceChild($fragment, $workingNode);
     $result = TemplateHelper::getRaw(preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\\s*~i', '', $dom->saveHTML()));
     if (strlen(trim($result)) === 0) {
         $result = craft()->lettering->{$class}($text);
         return $result ? $result[$class] : $text;
     }
     return $result;
 }
开发者ID:sjelfull,项目名称:Craft-Lettering,代码行数:38,代码来源:LetteringTwigExtension.php

示例15: get_element_by_id

function get_element_by_id($url, $id)
{
    $html = new DOMDocument();
    @$html->loadHTMLFile($url);
    $element = $html->getElementById($id);
    return $html->saveHTML($element);
}
开发者ID:juandodyk,项目名称:media-rss,代码行数:7,代码来源:scrap.php


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