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


PHP Reader::parse方法代码示例

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


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

示例1: testDeserialize

    function testDeserialize()
    {
        $input = <<<BLA
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
  <listThingy>
    <elem1 />
    <elem2 />
    <elem3 />
    <elem4 attr="val" />
    <elem5>content</elem5>
    <elem6><subnode /></elem6>
  </listThingy>
  <listThingy />
  <otherThing>
    <elem1 />
    <elem2 />
    <elem3 />
  </otherThing>
</root>
BLA;
        $reader = new Reader();
        $reader->elementMap = ['{http://sabredav.org/ns}listThingy' => 'Sabre\\Xml\\Element\\Elements'];
        $reader->xml($input);
        $output = $reader->parse();
        $this->assertEquals(['name' => '{http://sabredav.org/ns}root', 'value' => [['name' => '{http://sabredav.org/ns}listThingy', 'value' => ['{http://sabredav.org/ns}elem1', '{http://sabredav.org/ns}elem2', '{http://sabredav.org/ns}elem3', '{http://sabredav.org/ns}elem4', '{http://sabredav.org/ns}elem5', '{http://sabredav.org/ns}elem6'], 'attributes' => []], ['name' => '{http://sabredav.org/ns}listThingy', 'value' => [], 'attributes' => []], ['name' => '{http://sabredav.org/ns}otherThing', 'value' => [['name' => '{http://sabredav.org/ns}elem1', 'value' => null, 'attributes' => []], ['name' => '{http://sabredav.org/ns}elem2', 'value' => null, 'attributes' => []], ['name' => '{http://sabredav.org/ns}elem3', 'value' => null, 'attributes' => []]], 'attributes' => []]], 'attributes' => []], $output);
    }
开发者ID:sMataruev,项目名称:sabre-xml,代码行数:27,代码来源:ElementsTest.php

示例2: parse

 function parse($xml, array $elementMap = [])
 {
     $reader = new Reader();
     $reader->elementMap = array_merge($this->elementMap, $elementMap);
     $reader->xml($xml);
     return $reader->parse();
 }
开发者ID:Radiergummi,项目名称:anacronism,代码行数:7,代码来源:XmlTest.php

示例3: parse

 function parse($xml)
 {
     $reader = new Reader();
     $reader->elementMap['{DAV:}root'] = 'Sabre\\DAVACL\\Xml\\Property\\CurrentUserPrivilegeSet';
     $reader->xml($xml);
     $result = $reader->parse();
     return $result['value'];
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:8,代码来源:CurrentUserPrivilegeSetTest.php

示例4: read

 public function read($path)
 {
     parent::read($path);
     $reader = new Reader();
     $reader->xml($this->contents);
     $this->parsed = $reader->parse();
     return $this;
 }
开发者ID:kitbs,项目名称:twine,代码行数:8,代码来源:AbstractXML.php

示例5: testParseReturnsArray

 public function testParseReturnsArray()
 {
     $rw = new Realworks();
     $xmlString = file_get_contents('example.xml');
     $reader = new XML\Reader();
     $reader->xml($xmlString);
     $output = $reader->parse();
     $objects = $rw->parse($output);
     $this->assertInternalType('array', $objects);
 }
开发者ID:dennisenderink,项目名称:makelaars-import,代码行数:10,代码来源:RealworksTest.php

示例6: read

 protected function read($xmlFile)
 {
     $xml_contents = file_get_contents($xmlFile);
     $reader = new Reader();
     $reader->xml($xml_contents);
     $tree = $reader->parse();
     foreach ($tree['value'] as $node) {
         $key = $node['attributes']['name'];
         $value = $node['value'];
         $this->patterns[$key] = $value;
     }
 }
开发者ID:mermetbt,项目名称:biome,代码行数:12,代码来源:XMLLang.php

示例7: map

 /**
  * Build a response object
  *
  * @param \GuzzleHttp\Psr7\Response $response
  * @return Activity[]
  */
 public function map(Response $response)
 {
     // Pares XML
     $reader = new Reader();
     $reader->xml($response->getBody());
     $parse = $reader->parse();
     $return = [];
     foreach ($parse['value'] as $value) {
         $return[] = new Activity($value['attributes'], $value['value']);
     }
     return $return;
 }
开发者ID:betterweekdays,项目名称:onet,代码行数:18,代码来源:WorkActivityDetailed.php

示例8: testDeserialize

    /**
     * @expectedException \LogicException
     */
    function testDeserialize()
    {
        $input = <<<BLA
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
 <blabla />
</root>
BLA;
        $reader = new Reader();
        $reader->elementMap = ['{http://sabredav.org/ns}blabla' => 'Sabre\\Xml\\Element\\Cdata'];
        $reader->xml($input);
        $output = $reader->parse();
    }
开发者ID:sMataruev,项目名称:sabre-xml,代码行数:16,代码来源:CDataTest.php

示例9: testDeserialize

    /**
     * @dataProvider xmlProvider
     */
    function testDeserialize($input, $expected)
    {
        $input = <<<BLA
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
   <fragment>{$input}</fragment>
</root>
BLA;
        $reader = new Reader();
        $reader->elementMap = ['{http://sabredav.org/ns}fragment' => 'Sabre\\Xml\\Element\\XmlFragment'];
        $reader->xml($input);
        $output = $reader->parse();
        $this->assertEquals(['name' => '{http://sabredav.org/ns}root', 'value' => [['name' => '{http://sabredav.org/ns}fragment', 'value' => new XmlFragment($expected), 'attributes' => []]], 'attributes' => []], $output);
    }
开发者ID:sebbie42,项目名称:casebox,代码行数:17,代码来源:XmlFragmentTest.php

示例10: testDeserialize

    function testDeserialize()
    {
        $input = <<<BLA
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
  <uri>/foo/bar</uri>
</root>
BLA;
        $reader = new Reader();
        $reader->contextUri = 'http://example.org/';
        $reader->elementMap = ['{http://sabredav.org/ns}uri' => 'Sabre\\Xml\\Element\\Uri'];
        $reader->xml($input);
        $output = $reader->parse();
        $this->assertEquals(['name' => '{http://sabredav.org/ns}root', 'value' => [['name' => '{http://sabredav.org/ns}uri', 'value' => new Uri('http://example.org/foo/bar'), 'attributes' => []]], 'attributes' => []], $output);
    }
开发者ID:sebbie42,项目名称:casebox,代码行数:15,代码来源:UriTest.php

示例11: addIssuesFromXml

 /**
  * @inheritdoc
  */
 protected function addIssuesFromXml(Reader $xml)
 {
     $xmlArray = $xml->parse();
     foreach ((array) $xmlArray['value'] as $fileTag) {
         if ($fileTag['name'] != '{}file') {
             continue;
         }
         $fileName = $fileTag['attributes']['name'];
         foreach ((array) $fileTag['value'] as $issueTag) {
             $line = $issueTag['attributes']['beginline'];
             $tool = 'PHPMessDetector';
             $type = $issueTag['attributes']['rule'];
             $message = $issueTag['value'];
             $this->result->addIssue($fileName, $line, $tool, $type, $message);
         }
     }
 }
开发者ID:ricardorsierra,项目名称:php-hound,代码行数:20,代码来源:PHPMessDetector.php

示例12: loadFilename

 public static function loadFilename($filename)
 {
     $xml_contents = file_get_contents($filename);
     $reader = new Reader();
     /**
      * Loading components
      */
     $components_list = array();
     $components = scandir(__DIR__ . '/../../Component/');
     foreach ($components as $file) {
         if ($file[0] == '.') {
             continue;
         }
         if (substr($file, -4) != '.php') {
             continue;
         }
         $componentName = substr($file, 0, -strlen('Component.php'));
         $components_list['{http://github.com/mermetbt/Biome/}' . strtolower($componentName)] = 'Biome\\Component\\' . $componentName . 'Component';
     }
     $components_dirs = \Biome\Biome::getDirs('components');
     $components_dirs = array_reverse($components_dirs);
     foreach ($components_dirs as $dir) {
         if (!file_exists($dir)) {
             continue;
         }
         $components = scandir($dir);
         foreach ($components as $file) {
             if ($file[0] == '.') {
                 continue;
             }
             if (substr($file, -4) != '.php') {
                 continue;
             }
             $componentName = substr($file, 0, -strlen('Component.php'));
             $components_list['{http://github.com/mermetbt/Biome/}' . strtolower($componentName)] = $componentName . 'Component';
         }
     }
     $reader->elementMap = $components_list;
     /**
      * Parsing XML template
      */
     $reader->xml($xml_contents);
     $tree = $reader->parse();
     return $tree;
 }
开发者ID:mermetbt,项目名称:biome,代码行数:45,代码来源:TemplateReader.php

示例13: check

 public function check(Request $request)
 {
     // Check if Domain Name is available via API
     $domain = Domains::cleanURL(strtolower($request->input('domain')));
     // International Domain Names//
     if (Domains::isDomainIntl($domain)) {
         InternetBS::init('X1A7S0D7X8N0U0U0I6S2', 'Toto197500cxz');
         $status = InternetBS::api()->domainCheck($domain);
         if ($status) {
             $message = 'Domain Name is available';
         }
         $message = 'Domain Name is not available';
         return ['message' => $message, 'status' => $status];
     }
     // Rwandan Domain Names
     if (Domains::isDomainRW($domain)) {
         $params = ['form_params' => ['search' => $domain], 'verify' => false];
         $data = Domains::post('https://whois.ricta.org.rw/whois.jsp', $params);
         if (preg_match_all('/<tr><th>(?:[a-zA-Z\\s]+)<\\/th><td><a href=\'(.+)\'>(?:[a-zA-Z\\.]+)<\\/a>/im', $data, $matches)) {
             $status = false;
             $message = 'Domain Name is not available';
         } else {
             $message = 'Domain Name is available';
             $status = true;
         }
         return ['message' => $message, 'status' => $status];
     }
     // Ugandan Domain Names
     if (Domains::isDomainUG($domain)) {
         $xml = (string) Domains::post('https://new.registry.co.ug:8006/api', ['body' => Domains::UG_Whois_Command($domain)]);
         $reader = new Reader();
         $reader->xml($xml);
         $parsedXML = $reader->parse();
         $data = $parsedXML['value'];
         $status = (int) $parsedXML['attributes']['status'];
         if ($status) {
             $status = false;
             $message = 'Domain Name is Not available';
         } else {
             $message = 'Domain Name is available';
             $status = true;
         }
         return ['message' => $message, 'status' => $status];
     }
 }
开发者ID:antonioiradukunda,项目名称:kplhosting,代码行数:45,代码来源:ApiController.php

示例14: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Avoid PHP timeouts when querying large clusters
     set_time_limit(0);
     //Create Sabre XML Reader Object
     $reader = new Reader();
     //Create Guzzle REST client Object
     $client = new Client(['headers' => ['Accept' => 'application/xml', 'Content-Type' => 'application/xml']]);
     //Pick up the csv report created in the calling controller
     $csvFile = new CsvFile($this->csvFileName);
     //Write the csv headers
     $csvFile->writeRow(explode(',', $this->csv_headers));
     //Loop the devices in $this->deviceList to get firmware info
     foreach ($this->deviceList as $device) {
         //Only get firmware if the device is registered
         if ($device['IsRegistered']) {
             \Log::debug('Running with', [$device]);
             try {
                 //Query the phones web interface for the XML device info
                 $response = $client->get('http://' . $device['IpAddress'] . '/DeviceInformationX', ['connect_timeout' => 2]);
             } catch (RequestException $e) {
                 \Log::debug('Phone request exception', [$e]);
                 continue;
             }
             $body = $response->getBody()->getContents();
             \Log::debug('XML:', [$body]);
             //Consume the XML with Sabre XML Reader
             if ($reader->xml($body)) {
                 //Parse the XML
                 $deviceInfoX = $response = $reader->parse();
             } else {
                 \Log::debug('Error, there was no XML', []);
             }
             //Find the index for XML key holding the Firmware information
             $index = searchMultiDimArray($deviceInfoX['value'], 'name', '{}versionID');
             //Place the firmware info into our $device array
             $device['Firmware'] = $deviceInfoX['value'][$index]['value'];
         }
         //Write the firmware info to csv
         $csvFile->writeRow($device);
     }
 }
开发者ID:sloan58,项目名称:uc-insight-esk,代码行数:47,代码来源:GetPhoneFirmware.php

示例15: addIssuesFromXml

 /**
  * @inheritdoc
  */
 protected function addIssuesFromXml(Reader $xml)
 {
     $xmlArray = $xml->parse();
     foreach ((array) $xmlArray['value'] as $duplicationTag) {
         if ($duplicationTag['name'] != '{}duplication' || empty($duplicationTag['value'])) {
             continue;
         }
         foreach ((array) $duplicationTag['value'] as $fileTag) {
             if ($fileTag['name'] != '{}file') {
                 continue;
             }
             $fileName = $fileTag['attributes']['path'];
             $line = $fileTag['attributes']['line'];
             $tool = 'PHPCopyPasteDetector';
             $type = 'duplication';
             $message = 'Duplicated code';
             $this->result->addIssue($fileName, $line, $tool, $type, $message);
         }
     }
 }
开发者ID:GuidoBR,项目名称:php-hound,代码行数:23,代码来源:PHPCopyPasteDetector.php


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