简单的PHP库,用于DOM到对象的解析

v0.1.2 2019-12-30 21:06 UTC

This package is auto-updated.

Last update: 2024-09-06 06:45:35 UTC


README

简单的DOM到对象解析器

示例应用

请将此应用程序放入存储库根目录下的名为 'app' 的文件夹中。请参考 .gitignore - 它在那里被忽略

<?php

require dirname(__DIR__) . '/vendor/autoload.php';

$html = '<html>
  <head>
   <title>Parser test app</title>
  </head>
 <body>
  <div class="content">
   <h1>This is the header of test app</h1>
   <ul>
     <li>This is the first list item</li>
     <li>This is the second list item</li>
     <li>This is the third list item</li>
   </ul>
  </div>
 </body>
</html>';

$parser = new PhoenyxStudio\Parser\FakeParser();

$parseResult = $parser->parse($html);

$doc = $parseResult->ejectObject();

foreach($doc->getListItems() as $listItem) {
    echo $listItem . '<br>';
}