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


PHP DOMXPath::evaluate方法代码示例

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


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

示例1: unserialize

 /**
  * Unserializes the property.
  *
  * This static method should return a an instance of this object.
  *
  * @param \DOMElement $prop
  * @param array $propertyMap
  * @return DAV\IProperty
  */
 static function unserialize(\DOMElement $prop, array $propertyMap)
 {
     $xpath = new \DOMXPath($prop->ownerDocument);
     $xpath->registerNamespace('d', 'urn:DAV');
     // Finding the 'response' element
     $xResponses = $xpath->evaluate('d:response', $prop);
     $result = [];
     for ($jj = 0; $jj < $xResponses->length; $jj++) {
         $xResponse = $xResponses->item($jj);
         // Parsing 'href'
         $href = Href::unserialize($xResponse, $propertyMap);
         $properties = [];
         // Parsing 'status' in 'd:response'
         $responseStatus = $xpath->evaluate('string(d:status)', $xResponse);
         if ($responseStatus) {
             list(, $responseStatus, ) = explode(' ', $responseStatus, 3);
         }
         // Parsing 'propstat'
         $xPropstat = $xpath->query('d:propstat', $xResponse);
         for ($ii = 0; $ii < $xPropstat->length; $ii++) {
             // Parsing 'status'
             $status = $xpath->evaluate('string(d:status)', $xPropstat->item($ii));
             list(, $statusCode, ) = explode(' ', $status, 3);
             $usedPropertyMap = $statusCode == '200' ? $propertyMap : [];
             // Parsing 'prop'
             $properties[$statusCode] = DAV\XMLUtil::parseProperties($xPropstat->item($ii), $usedPropertyMap);
         }
         $result[] = new Response($href->getHref(), $properties, $responseStatus ? $responseStatus : null);
     }
     return new self($result);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:40,代码来源:ResponseList.php

示例2: parse

 /**
  * Parses the request.
  *
  * @return void
  */
 public function parse()
 {
     $filterNode = null;
     $limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)');
     if (is_nan($limit)) {
         $limit = null;
     }
     $filter = $this->xpath->query('/card:addressbook-query/card:filter');
     if ($filter->length !== 1) {
         throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
     }
     $filter = $filter->item(0);
     $test = $this->xpath->evaluate('string(@test)', $filter);
     if (!$test) {
         $test = self::TEST_ANYOF;
     }
     if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) {
         throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"');
     }
     $propFilters = array();
     $propFilterNodes = $this->xpath->query('card:prop-filter', $filter);
     for ($ii = 0; $ii < $propFilterNodes->length; $ii++) {
         $propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii));
     }
     $this->filters = $propFilters;
     $this->limit = $limit;
     $this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild));
     $this->test = $test;
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:34,代码来源:AddressBookQueryParser.php

示例3: parse

 function parse()
 {
     $x = new DOMXPath($this->dom);
     $paragraphes = $x->evaluate('//*[@id="posts"]/li[ @id and not( contains(@class,"with_avatar") ) and not(@class="post") ]', $x->document);
     // prevent to leak sessionkey via referer.
     $anchors = $x->evaluate('//*[@id="posts"]/li//a', $x->document);
     foreach ($anchors as $k => $v) {
         $u = $v->getAttribute('href');
         if (preg_match('%^http://%i', $u)) {
             $u = to_mobile_url($u);
             $v->setAttribute('href', $u);
             $u = $v->getAttribute('href');
         }
     }
     $images = $x->evaluate('//*[@id="posts"]/li//img[ not(ancestor::li[contains(@class,"photo")]) ]', $x->document);
     foreach ($images as $k => $v) {
         $u = $v->getAttribute('src');
         if (!preg_match('%^http:\\/\\/(media|data|assets)\\.tumblr\\.com%i', (string) $u)) {
             $v->setAttribute('xOriginalsrc', $u);
             $v->setAttribute('src', '');
         }
     }
     $posts = array();
     foreach ($paragraphes as $k => $paragraph) {
         $posts[] = $p = new Post($x, $paragraph);
         $p->getPostInfo();
     }
     $this->posts = $posts;
 }
开发者ID:ku,项目名称:reblog.ido.nu,代码行数:29,代码来源:Dashboard_Class.php

示例4: threadParse

 protected function threadParse($raw)
 {
     $xml = new SimpleXMLElement($raw);
     $json = $xml->json;
     $html = $this->ampsfix($xml->html);
     $dom = new DOMDocument();
     @$dom->loadHTML($html);
     $dom->normalizeDocument();
     $xpath = new DOMXPath($dom);
     $array = [];
     $imgs = $xpath->evaluate('/html/body//div/div/div/table/tr/td/div/table/tr/td/table/tr/td/div/img');
     $i = 0;
     foreach ($imgs as $img) {
         $t = explode('?', $img->getAttribute('src'));
         $array[$i]['user']['avatar'] = $t[0];
         $i++;
     }
     $ppl = $xpath->evaluate('/html/body//div/div/div/table/tr/td/div/table/tr/td/table/tr/td/div/span/a');
     $i = 0;
     foreach ($ppl as $pp) {
         $t = $pp->nodeValue;
         $array[$i]['user']['name'] = $t;
         $i++;
     }
     return $array;
 }
开发者ID:navarr,项目名称:gvPHP,代码行数:26,代码来源:index.php

示例5: NewDocRequest

function NewDocRequest($order_id)
{
    global $customer_id, $abo_id;
    FB::info('NewDocRequest Nummer' . $abo_id);
    if (SOAP_SERVER != '') {
        $client = new SoapClient(null, array('location' => SOAP_SERVER, 'uri' => SOAP_NAMESPACE, 'trace' => true, 'connection_timeout' => 5));
        $response = $client->__doRequest('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
		  <SOAP-ENV:Body>
			<NewDocRequest xmlns="test">
				<Nummer>' . $abo_id . '</Nummer>
				<Soort>B</Soort>
				<Weborder>' . $order_id . '</Weborder>
			</NewDocRequest>
		  </SOAP-ENV:Body>
		</SOAP-ENV:Envelope>', SOAP_SERVER, SOAP_NAMESPACE, SOAP_1_2);
        if ($response) {
            $dom = new DOMDocument();
            $dom->loadXML($response);
            $xPath = new DOMXPath($dom);
            $result = array();
            if ($xPath->evaluate("//Status")->item(0)->nodeValue == 0) {
                $result = $xPath->evaluate("//StatusTekst")->item(0)->nodeValue;
            } else {
                $result = $xPath->evaluate("//Document")->item(0)->nodeValue;
            }
        }
    }
    return $result;
}
开发者ID:CristianCCIT,项目名称:shop4office,代码行数:29,代码来源:NewDocRequest.php

示例6: discourse

 private function discourse($volume, $discourse)
 {
     $this->Discourse =& ClassRegistry::init('Discourse');
     $volume = str_pad((int) $volume, 2, "0", STR_PAD_LEFT);
     $discourse = str_pad($discourse, 2, "0", STR_PAD_LEFT);
     App::import('Core', array('Xml', 'HttpSocket'));
     $this->Http =& new HttpSocket();
     $url = "http://scriptures.byu.edu/gettalk.php?vol={$volume}&disc={$discourse}";
     $html = $this->Http->get($url);
     if (strpos($html, 'file_get_contents') !== false) {
         return false;
     }
     $dom = new DOMDocument();
     @$dom->loadHTML($html);
     $xpath = new DOMXPath($dom);
     $start_page = (int) $xpath->evaluate('//a[@name][1]')->item(0)->getAttribute('name');
     $column_anchors = $xpath->evaluate('//a[@name]');
     $end_page = (int) $column_anchors->item($column_anchors->length - 1)->getAttribute('name');
     $title = clean_string(find_content($xpath, '//div[@class="title"]'));
     $subtitle = find_content($xpath, '//div[@class="subtitle"]');
     $reported_by = clean_string(find_content($xpath, '//div[@class="reportedBy"]'));
     $page_header = clean_string(find_content($xpath, '//div[@class="pageHeader"]'));
     $speaker = clean_string(find_content($xpath, '//div[@class="speaker"]'));
     $date = prepare_date(find_content($xpath, '//div[@class="date"]'));
     $content = find_content($xpath, '//div[@class="discourseBody"]');
     $this->Discourse->create();
     $this->Discourse->save(array('volume' => $volume, 'start_page' => $start_page, 'end_page' => $end_page, 'title' => $title, 'subtitle' => $subtitle, 'reported_by' => $reported_by, 'page_header' => $page_header, 'speaker' => $speaker, 'date' => $date, 'subtitle' => $subtitle, 'content' => $content));
     return true;
 }
开发者ID:aaronshaf,项目名称:jod,代码行数:29,代码来源:import_controller.php

示例7: getDate

 public function getDate()
 {
     $date_string = $this->xpath->evaluate("string(pubDate)", $this->element);
     $unix_time = strtotime($date_string);
     $date = new SwatDate();
     $date->setTimestamp($unix_time);
     $date->toUTC();
     return $date;
 }
开发者ID:nburka,项目名称:news-flash,代码行数:9,代码来源:NewsFlashRSSItem.php

示例8: GetStockMaat

function GetStockMaat($product_id, $maat, $data)
{
    if (SOAP_SERVER != '') {
        $get_model_query = tep_db_query("select products_model, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "'");
        $get_model = tep_db_fetch_array($get_model_query);
        $client = new SoapClient(null, array('location' => SOAP_SERVER, 'uri' => SOAP_NAMESPACE, 'trace' => true, 'connection_timeout' => 5));
        $response = $client->__doRequest('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
		  <SOAP-ENV:Body>
			<ns1:stockRequest>
			  <Artikel>' . $get_model['products_model'] . '</Artikel>
			  <Maat>' . $maat . '</Maat>
			</ns1:stockRequest>
		  </SOAP-ENV:Body>
		</SOAP-ENV:Envelope>', SOAP_SERVER, SOAP_NAMESPACE, SOAP_1_2);
        if ($response) {
            $dom = new DOMDocument();
            $dom->loadXML($response);
            $xPath = new DOMXPath($dom);
            if ($xPath->evaluate("//Status")->item(0)->nodeValue == 0) {
                $result = $xPath->evaluate("//StatusTekst")->item(0)->nodeValue;
            } else {
                //Article contains XML inside, need to reparse it
                $dom->loadXML('<xml>' . $xPath->evaluate("//Artikel")->item(0)->nodeValue . '</xml>');
                $xPath = new DOMXPath($dom);
                $elements = $xPath->evaluate("//xml/*");
                if ($maat == '') {
                    foreach ($elements as $element) {
                        if ($element->nodeName == 'Maten') {
                            continue;
                        }
                        if ($element->nodeName == $data) {
                            $result .= $element->nodeValue . ' ';
                        }
                    }
                } else {
                    $maats = $xPath->evaluate("//xml/Maten/Maat");
                    if ($maats->length > 0) {
                        foreach ($maats as $maat) {
                            $elements = $xPath->evaluate("child::*", $maat);
                            foreach ($elements as $element) {
                                if ($element->nodeName == $data) {
                                    $result .= $element->nodeValue;
                                }
                            }
                        }
                    }
                }
            }
        } else {
            tep_mail('ABO Service Monitor', 'mattias@aboservice.be', 'SOAP Server offline', 'De SOAP Server op ' . STORE_NAME . ' - ' . HTTP_SERVER . ' is offline', STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);
            $result .= $get_model['products_quantity'];
        }
    } else {
        $result = 'No SOAP server defined. Please check configuration';
    }
    return $result;
}
开发者ID:CristianCCIT,项目名称:shop4office,代码行数:57,代码来源:GetStockMaat.php

示例9: __construct

 /**
  * Construct the Send object by parsing the XML.
  * @param xml_doc the DOM XML document
  * @exception if the response is not valid
  */
 public function __construct(\DOMDocument $xml_doc)
 {
     parent::__construct($xml_doc);
     $xpath = new \DOMXPath($xml_doc);
     $this->message_id = $xpath->evaluate('/response/message_id')->item(0)->nodeValue;
     $this->hash = $xpath->evaluate('/response/hash')->item(0)->nodeValue;
     if (!isset($this->message_id, $this->hash)) {
         throw new \Exception('An error occured while parsing the XML data for the SEND call');
     }
 }
开发者ID:SerdarSanri,项目名称:mogreet,代码行数:15,代码来源:Send.class.php

示例10: testAssertEqualXMLStructure

 public function testAssertEqualXMLStructure()
 {
     $doc = new DOMDocument();
     $doc->loadXML('<root><label>text content</label></root>');
     $xpath = new DOMXPath($doc);
     $labelElement = $doc->getElementsByTagName('label')->item(0);
     $this->assertEquals(1, $xpath->evaluate('count(//label[text() = "text content"])'));
     $expectedElmt = $doc->createElement('label', 'text content');
     $this->assertEqualXMLStructure($expectedElmt, $labelElement);
     // the following assertion fails, even though it passed before - which is due to the assertEqualXMLStructure() has modified the $labelElement
     $this->assertEquals(1, $xpath->evaluate('count(//label[text() = "text content"])'));
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:12,代码来源:Issue1472Test.php

示例11: __construct

 /**
  * Construct the Setopt object by parsing the XML.
  * @param xml_doc the DOM XML document
  * @exception if the response is not valid
  */
 public function __construct(\DOMDocument $xml_doc)
 {
     parent::__construct($xml_doc);
     $xpath = new \DOMXPath($xml_doc);
     $this->campaign_id = $xpath->evaluate('/response/campaign/@id')->item(0)->nodeValue;
     $this->campaign_status_code = $xpath->evaluate('/response/campaign/status/@code')->item(0)->nodeValue;
     $this->campaign_status = $xpath->evaluate('/response/campaign/status')->item(0)->nodeValue;
     $this->number = $xpath->evaluate('/response/number')->item(0)->nodeValue;
     if (!isset($this->campaign_id, $this->campaign_status_code, $this->campaign_status, $this->number)) {
         throw new \Exception('An error occured while parsing the XML data for the SETOPT call.');
     }
 }
开发者ID:SerdarSanri,项目名称:mogreet,代码行数:17,代码来源:Setopt.class.php

示例12: baseFromHTML

 public static function baseFromHTML($doc, $htmlURL)
 {
     $xpath = new DOMXPath($doc);
     $xpath->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');
     if ($url = $xpath->evaluate('string(//head/base/@href)')) {
         return $url;
     }
     if ($url = $xpath->evaluate('string(//xhtml:head/xhtml:base/@href)')) {
         return $url;
     }
     return $htmlURL;
 }
开发者ID:yech1990,项目名称:enhanced_paper_rss,代码行数:12,代码来源:Util.php

示例13: parser

 public static function parser($url)
 {
     self::checkUrl($url);
     $dom = new DOMDocument();
     @$dom->loadHTMLFile($url);
     $xpath = new DOMXPath($dom);
     $arrEntry = array();
     foreach ($xpath->query('//table[@id="ranking_table"]/tr') as $node) {
         $arrEntry[] = ['rank' => (int) str_replace(array("位"), "", $xpath->evaluate('normalize-space(td[1]/div/strong)', $node)), 'work' => ['title' => $xpath->evaluate('normalize-space(td[3]/dl[@class="work_1col"]/dt[@class="work_name"]/a)', $node), 'url' => $xpath->evaluate('normalize-space(td[3]/dl[@class="work_1col"]/dt[@class="work_name"]/a/@href)', $node), 'thumbnail_url' => "http:" . $xpath->evaluate('normalize-space(td[2]/div/a/img/@src)', $node), 'price' => $xpath->evaluate('normalize-space(td[3]/dl[@class="work_1col"]/dd[@class="work_price"])', $node), 'description' => $xpath->evaluate('normalize-space(td[3]/dl[@class="work_1col"]/dd[@class="work_text"])', $node), 'genre' => self::convertNodesToNodeValueArray($xpath->query('td[3]/dl[@class="work_1col"]/dd[@class="work_genre"]//span', $node)), 'date' => str_replace(array("販売日: "), "", $xpath->evaluate('normalize-space(td[4]/ul[1]/li[1])', $node)), 'download_count' => (int) $xpath->evaluate('normalize-space(td[4]/ul[2]/li[1]/div/span)', $node)], 'maker' => ['title' => $xpath->evaluate('normalize-space(td[3]/dl[@class="work_1col"]/dd[@class="maker_name"]/a)', $node), 'url' => $xpath->evaluate('normalize-space(td[3]/dl[@class="work_1col"]/dd[@class="maker_name"]/a/@href)', $node)]];
     }
     return $arrEntry;
 }
开发者ID:seiyaan,项目名称:DLsiteRankingApi,代码行数:12,代码来源:DLsiteDomParser.php

示例14: __construct

 /**
  * Construct the Info object by parsing the XML.
  * @param xml_doc the DOM XML document
  * @exception if the response is not valid
  */
 public function __construct(\DOMDocument $xml_doc)
 {
     parent::__construct($xml_doc);
     $xpath = new \DOMXPath($xml_doc);
     $this->number = $xpath->evaluate('/response/number')->item(0)->nodeValue;
     $this->carrier_id = $xpath->evaluate('/response/carrier/@id')->item(0)->nodeValue;
     $this->carrier = $xpath->evaluate('/response/carrier')->item(0)->nodeValue;
     $this->handset_id = $xpath->evaluate('/response/handset/@id')->item(0)->nodeValue;
     $this->handset = $xpath->evaluate('/response/handset')->item(0)->nodeValue;
     if (!isset($this->number, $this->carrier_id, $this->carrier, $this->handset_id, $this->handset)) {
         throw new \Exception("Invalid Info response.");
     }
 }
开发者ID:SerdarSanri,项目名称:mogreet,代码行数:18,代码来源:Info.class.php

示例15: frontendPrePageResolve

 public function frontendPrePageResolve($context)
 {
     $document = new DOMDocument();
     $document->load(MANIFEST . '/rewrite.xml');
     $xpath = new DOMXPath($document);
     $url = $_SERVER['REQUEST_URI'];
     if (strpos($url, __SYM_COOKIE_PATH__) == 0) {
         $url = substr($url, strlen(__SYM_COOKIE_PATH__));
     }
     $url = trim($url, '/');
     foreach ($xpath->query('/rewrite/rule') as $rule) {
         $match = $xpath->evaluate('string(match/text())', $rule);
         $case = $xpath->evaluate('boolean(match/@case-sensetive = "yes")', $rule);
         $replace = $xpath->evaluate('string(replace/text())', $rule);
         // Escape slashes:
         $match = str_replace('/', '\\/', $match);
         // Add regexp flags:
         $match = '/' . $match . '/' . ($case ? '' : 'i');
         if (preg_match($match, $url, $matches)) {
             $bits = preg_split('/(\\\\[0-9]+)/', $replace, 0, PREG_SPLIT_DELIM_CAPTURE);
             $redirect = '';
             foreach ($bits as $bit) {
                 if (preg_match('/^\\\\[0-9]+$/', $bit)) {
                     $index = (int) trim($bit, '\\');
                     if (isset($matches[$index])) {
                         $redirect .= $matches[$index];
                     }
                     continue;
                 }
                 $redirect .= $bit;
             }
             break;
         }
     }
     // Found a new URL:
     if (isset($redirect)) {
         $url = parse_url($redirect);
         $symphony_page = trim($url['path'], '/');
         $query_string = $url['query'] . '&symphony-page=' . $symphony_page;
         $query_array = $this->parseQueryString($query_string);
         $context['page'] = '/' . $symphony_page . '/';
         $_SERVER['QUERY_STRING'] = $query_string;
         $_GET = $query_array;
         // Set headers
         foreach ($xpath->query('header', $rule) as $header) {
             $name = $header->getAttribute('name');
             $value = $header->getAttribute('value');
             self::$headers[$name] = $value;
         }
     }
 }
开发者ID:psychoticmeowArchives,项目名称:rewrite,代码行数:51,代码来源:extension.driver.php


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