Adding unoconv see BT#7058

1.10.x
Julio Montoya 12 years ago
parent da5fd1afb8
commit 255c085700
  1. 3
      composer.json
  2. 1
      main/inc/global.inc.php
  3. 23
      main/inc/services.php
  4. 1571
      main/wiki/index.php
  5. 2458
      main/wiki/wiki.inc.php
  6. 98
      src/ChamiloLMS/Component/DataFilesystem/DataFilesystem.php
  7. 33
      src/ChamiloLMS/Component/Editor/Connector.php
  8. 18
      src/ChamiloLMS/Component/Editor/Driver/CourseDriver.php
  9. 2
      src/ChamiloLMS/Component/Editor/Driver/CourseUserDriver.php
  10. 2
      src/ChamiloLMS/Component/Editor/Driver/DropBoxDriver.php
  11. 2
      vendor/autoload.php
  12. 24
      vendor/composer/autoload_classmap.php
  13. 1
      vendor/composer/autoload_namespaces.php
  14. 10
      vendor/composer/autoload_real.php
  15. 45
      vendor/composer/installed.json
  16. 38
      vendor/sunra/php-simple-html-dom-parser/README.md
  17. 20
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/HtmlDomParser.php
  18. 891
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/google.htm
  19. 144
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/index.php
  20. BIN
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/images/treeview-default-line.gif
  21. BIN
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/images/treeview-default.gif
  22. 3363
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.js
  23. 68
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.treeview.css
  24. 251
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.treeview.js
  25. 24
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/screen.css
  26. 109
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/change_log.txt
  27. 54
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_advanced_selector.php
  28. 37
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_basic_selector.php
  29. 28
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_callback.php
  30. 5
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_extract_html.php
  31. 18
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_modify_contents.php
  32. 44
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_digg.php
  33. 51
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_imdb.php
  34. 35
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_slashdot.php
  35. 35
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/simple_html_dom_utility.php
  36. 113
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/css/default.css
  37. 116
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/css/ui.tabs.css
  38. BIN
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/img/tab.png
  39. 11
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/js/jquery-1.2.3.pack.js
  40. 10
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/js/ui.tabs.pack.js
  41. 448
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual.htm
  42. 320
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual_api.htm
  43. 91
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual_faq.htm
  44. 1721
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php
  45. 24
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/all_test.php
  46. 74
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/callback_testcase.php
  47. 386
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/dom_testcase.php
  48. 247
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/element_testcase.php
  49. 658
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/invalid_testcase.php
  50. 11
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/jquery-1.2.3.pack.js
  51. 68
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/mass_test.php
  52. 121
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/memory_test.php
  53. 60
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/misc_testcase.php
  54. 40
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/performance_test.php
  55. 12
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/all_test.php
  56. 243
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/element_testcase.php
  57. 103
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/memory_test.php
  58. 38
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/performance_test.php
  59. 584
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/selector_testcase.php
  60. 742
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/selector_testcase.php
  61. 27
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/slick_test.php
  62. 2888
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/slickspeed.htm
  63. 243
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/std_testcase.php
  64. 137
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/strip_testcase.php
  65. 24
      vendor/sunra/php-simple-html-dom-parser/composer.json
  66. 6
      web/ChamiloLMS/css/base.css

@ -86,7 +86,8 @@
"opauth/google": "0.2.2",
"media-alchemyst/media-alchemyst": "0.3.6",
"php-ffmpeg/php-ffmpeg": "0.4.4",
"php-unoconv/php-unoconv": "0.3.0"
"php-unoconv/php-unoconv": "0.3.0",
"sunra/php-simple-html-dom-parser": "1.5.0"
},
"require-dev": {
"knplabs/gaufrette": "0.2.*@dev",

@ -584,6 +584,7 @@ $app->before(
} else {
$app['course'] = null;
}
$app['session']->set('course_session', $app['course']);
$studentView = $request->get('isStudentView');
if (!empty($studentView)) {

@ -637,7 +637,12 @@ class ChamiloServiceProvider implements ServiceProviderInterface
// Chamilo data filesystem.
$app['chamilo.filesystem'] = $app->share(function () use ($app) {
$filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem($app['paths'], $app['filesystem']);
$filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem(
$app['paths'],
$app['filesystem'],
$app['editor_connector'],
$app['unoconv']
);
return $filesystem;
});
@ -857,6 +862,7 @@ $app['html_editor'] = $app->share(function($app) {
$app['editor_connector'] = $app->share(function ($app) {
$token = $app['security']->getToken();
$user = $token->getUser();
$course = $app['session']->get('course_session');
return new Connector(
$app['orm.em'],
@ -865,15 +871,26 @@ $app['editor_connector'] = $app->share(function ($app) {
$app['translator'],
$app['security'],
$user,
$app['course']
$course
);
});
$app->register(new Unoconv\UnoconvServiceProvider(), array(
'unoconv.configuration' => array(
'unoconv.binaries' => $app['configuration']['unoconv.binaries'],
'timeout' => 42,
),
'unoconv.logger' => $app->share(function () use ($app) {
return $app['monolog']; // use Monolog service provider
}),
));
/*
$app->register(
new ChamiloLMS\Provider\BootstrapSilexProvider(),
array(
)
);*/
);*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -6,6 +6,10 @@ use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Console;
use Unoconv\Unoconv;
use Sunra\PhpSimple\HtmlDomParser;
use ChamiloLMS\Component\Editor\Connector;
use ChamiloLMS\Component\Editor\Driver\CourseDriver;
/**
* @todo use Gaufrette to manage course files (some day)
@ -24,11 +28,15 @@ class DataFilesystem
/**
* @param array $paths
* @param Filesystem $filesystem
* @param Unoconv $unoconv
*/
public function __construct($paths, Filesystem $filesystem)
public function __construct($paths, Filesystem $filesystem, Connector $editor, $unoconv = null)
{
$this->paths = $paths;
$this->fs = $filesystem;
$this->unoconv = $unoconv;
$this->editor = $editor;
$this->editor->setDriver('CourseDriver');
}
/**
@ -140,4 +148,92 @@ class DataFilesystem
$styleSheetFolder = $this->paths['root_sys'].'main/css';
return $finder->directories()->depth('== 0')->in($styleSheetFolder);
}
/**
* Creates a empty file inside the temp folder
* @param string $fileName
* @param string $extension
* @return string
*/
public function createTempFile($fileName = null, $extension = null)
{
if (empty($fileName)) {
$fileName = mt_rand();
}
if (!empty($extension)) {
$extension = ".$extension";
}
$filePath = $this->paths['sys_temp_path'].$fileName.$extension;
$this->fs->touch($filePath);
if ($this->fs->exists($filePath)) {
return $filePath;
}
return null;
}
/**
* Converts ../courses/ABC/document/file.jpg to
* http://chamilo/courses/ABC/document/file.jpg
* @param string $content
* @return string
*/
public function convertRelativeToAbsoluteUrl($content)
{
/** @var CourseDriver $courseDriver */
$courseDriver = $this->editor->getDriver('CourseDriver');
$dom = HtmlDomParser::str_get_html($content);
//var_dump($this->editor->getDrivers());
/** @var \simple_html_dom_node $image */
foreach ($dom->find('img') as $image) {
$image->src = str_replace(
$courseDriver->getCourseDocumentRelativeWebPath(),
$courseDriver->getCourseDocumentWebPath(),
$image->src
);
}
return $dom;
}
/**
* Save string in a temp file
* @param string $content
* @param string $fileName
* @param string $extension
*
* @return string file path
*/
public function putContentInTempFile($content, $filename = null, $extension = null)
{
$file = $this->createTempFile($filename, $extension);
if (!empty($file)) {
$this->fs->dumpFile($file, $content);
return $file;
}
return null;
}
/**
* @param string $filePath
* @param string $format
* @return string
*/
public function transcode($filePath, $format)
{
if ($this->fs->exists($filePath)) {
$fileInfo = pathinfo($filePath);
$fileName = $fileInfo['filename'];
$newFilePath = str_replace(
$fileInfo['basename'],
$fileName.'.'.$format, $filePath
);
$this->unoconv->transcode($filePath, $format, $newFilePath);
if ($this->fs->exists($newFilePath)) {
return $newFilePath;
}
}
return false;
}
}

@ -170,7 +170,6 @@ class Connector
return $driverUpdated;
}
/**
* Get default driver settings.
* @return array
@ -269,19 +268,35 @@ class Connector
)
);
foreach ($this->getDriverList() as $driverName) {
$driverClass = $this->getDriverClass($driverName);
/** @var Driver $driver */
$driver = new $driverClass();
$driver->setName($driverName);
$driver->setConnector($this);
$this->addDriver($driver);
}
$this->setDrivers();
$opts['roots'] = $this->getRoots();
return $opts;
}
/**
* Set drivers from list
*/
public function setDrivers()
{
foreach ($this->getDriverList() as $driverName) {
$this->setDriver($driverName);
}
}
/**
* Sets a driver.
* @param string $driverName
*/
public function setDriver($driverName)
{
$driverClass = $this->getDriverClass($driverName);
/** @var Driver $driver */
$driver = new $driverClass();
$driver->setName($driverName);
$driver->setConnector($this);
$this->addDriver($driver);
}
/**
* Simple function to demonstrate how to control file access using "accessControl" callback.

@ -22,7 +22,7 @@ class CourseDriver extends Driver
return array(
'driver' => 'CourseDriver',
'path' => $this->getCourseDocumentSysPath(),
'URL' => $this->getCourseDocumentWebPath(),
'URL' => $this->getCourseDocumentRelativeWebPath(),
'accessControl' => array($this, 'access'),
'alias' => $alias,
'attributes' => array(
@ -58,7 +58,7 @@ class CourseDriver extends Driver
/**
* @return string
*/
public function getCourseDocumentWebPath()
public function getCourseDocumentRelativeWebPath()
{
$url = null;
if (isset($this->connector->course)) {
@ -68,6 +68,20 @@ class CourseDriver extends Driver
return $url;
}
/**
* @return string
*/
public function getCourseDocumentWebPath()
{
$url = null;
if (isset($this->connector->course)) {
$directory = $this->connector->course->getDirectory();
$url = api_get_path(WEB_DATA_COURSE_PATH).$directory.'/document/';
}
return $url;
}
/**
* {@inheritdoc}
*/

@ -28,7 +28,7 @@ class CourseUserDriver extends CourseDriver
'alias' => $alias,
'path' => $this->getCourseDocumentSysPath().$path,
//'alias' => $courseInfo['code'].' personal documents',
'URL' => $this->getCourseDocumentWebPath().$path,
'URL' => $this->getCourseDocumentRelativeWebPath().$path,
'accessControl' => 'access'
);
}

@ -81,7 +81,7 @@ class DropBoxDriver extends \elFinderVolumeMySQL implements InterfaceDriver
'alias' => 'dropbox',
'tmpPath' => $this->connector->paths['sys_temp_path'],
//'alias' => $courseInfo['code'].' personal documents',
//'URL' => $this->getCourseDocumentWebPath().$path,
//'URL' => $this->getCourseDocumentRelativeWebPath().$path,
'accessControl' => 'access'
);
}

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581::getLoader();
return ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce::getLoader();

@ -11,10 +11,6 @@ return array(
'Absolute_Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/absolute_positioner.cls.php',
'AbstractLink' => $baseDir . '/main/gradebook/lib/be/abstractlink.class.php',
'Abstract_Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/abstract_renderer.cls.php',
'Access' => $baseDir . '/main/inc/lib/access.class.php',
'AccessAll' => $baseDir . '/main/inc/lib/access.class.php',
'AccessForbidden' => $baseDir . '/main/inc/lib/access.class.php',
'AccessToken' => $baseDir . '/main/inc/lib/access_token.class.php',
'Accessurleditcoursestourl' => $baseDir . '/main/inc/lib/access_url_edit_courses_to_url_functions.lib.php',
'Accessurleditsessionstourl' => $baseDir . '/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.php',
'Accessurledituserstourl' => $baseDir . '/main/inc/lib/access_url_edit_users_to_url_functions.lib.php',
@ -22,7 +18,6 @@ return array(
'AddManySessionToCategoryFunctions' => $baseDir . '/main/inc/lib/add_many_session_to_category_functions.lib.php',
'AdminPage' => $baseDir . '/main/admin/admin_page.class.php',
'Agenda' => $baseDir . '/main/inc/lib/agenda.lib.php',
'AjaxController' => $baseDir . '/main/inc/lib/ajax_controller.class.php',
'Announcement' => $baseDir . '/main/coursecopy/classes/Announcement.class.php',
'AnnouncementEmail' => $baseDir . '/main/inc/lib/announcement_email.class.php',
'AnnouncementManager' => $baseDir . '/main/inc/lib/announcements.inc.php',
@ -59,14 +54,12 @@ return array(
'Cellmap' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/cellmap.cls.php',
'Certificate' => $baseDir . '/main/inc/lib/certificate.lib.php',
'Cezpdf' => $baseDir . '/main/inc/lib/ezpdf/class.ezpdf.php',
'Chamilo' => $baseDir . '/main/inc/lib/chamilo.class.php',
'ChamiloIndexer' => $baseDir . '/main/inc/lib/search/ChamiloIndexer.class.php',
'ChamiloSession' => $baseDir . '/main/inc/lib/chamilo_session.class.php',
'Chat' => $baseDir . '/main/inc/lib/chat.lib.php',
'ClassManager' => $baseDir . '/main/inc/lib/classmanager.lib.php',
'Collator' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php',
'ConditionalLogin' => $baseDir . '/main/inc/lib/conditional_login.class.php',
'Controller' => $baseDir . '/main/inc/lib/controller.class.php',
'Converter' => $baseDir . '/main/inc/lib/system/text/converter.class.php',
'Course' => $baseDir . '/main/coursecopy/classes/Course.class.php',
'CourseArchiver' => $baseDir . '/main/coursecopy/classes/CourseArchiver.class.php',
@ -74,8 +67,6 @@ return array(
'CourseCopyAttendance' => $baseDir . '/main/coursecopy/classes/Attendance.class.php',
'CourseCopyLearnpath' => $baseDir . '/main/coursecopy/classes/CourseCopyLearnpath.class.php',
'CourseDescription' => $baseDir . '/main/inc/lib/course_description.lib.php',
'CourseEntity' => $baseDir . '/main/inc/lib/course_entity.class.php',
'CourseEntityRepository' => $baseDir . '/main/inc/lib/course_entity_repository.class.php',
'CourseHome' => $baseDir . '/main/inc/lib/course_home.lib.php',
'CourseManager' => $baseDir . '/main/inc/lib/course.lib.php',
'CourseRecycler' => $baseDir . '/main/coursecopy/classes/CourseRecycler.class.php',
@ -189,8 +180,6 @@ return array(
'DummyCourseCreator' => $baseDir . '/main/coursecopy/classes/DummyCourseCreator.class.php',
'Encoding' => $baseDir . '/main/inc/lib/system/text/encoding.class.php',
'EncodingConverter' => $baseDir . '/main/inc/lib/system/text/encoding_converter.class.php',
'Entity' => $baseDir . '/main/inc/lib/entity.class.php',
'EntityRepository' => $baseDir . '/main/inc/lib/entity_repository.class.php',
'EvalForm' => $baseDir . '/main/gradebook/lib/fe/evalform.class.php',
'EvalLink' => $baseDir . '/main/gradebook/lib/be/evallink.class.php',
'Evaluation' => $baseDir . '/main/gradebook/lib/be/evaluation.class.php',
@ -211,7 +200,6 @@ return array(
'FacebookApiException' => $baseDir . '/main/auth/external_login/facebook-php-sdk/src/base_facebook.php',
'FileManager' => $baseDir . '/main/inc/lib/fileManager.lib.php',
'FileReader' => $baseDir . '/main/inc/lib/system/io/file_reader.class.php',
'FileStore' => $baseDir . '/main/inc/lib/file_store.class.php',
'FileWriter' => $baseDir . '/main/inc/lib/system/io/file_writer.class.php',
'FillBlanks' => $baseDir . '/main/exercice/fill_blanks.class.php',
'FlatViewDataGenerator' => $baseDir . '/main/gradebook/lib/flatview_data_generator.class.php',
@ -364,7 +352,6 @@ return array(
'Inline_Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/inline_positioner.cls.php',
'Inline_Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/inline_renderer.cls.php',
'IntlDateFormatter' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php',
'Javascript' => $baseDir . '/main/inc/lib/javascript.class.php',
'Javascript_Embedder' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/javascript_embedder.cls.php',
'KeyAuth' => $baseDir . '/main/auth/key/key_auth.class.php',
'LearnpathLink' => $baseDir . '/main/gradebook/lib/be/learnpathlink.class.php',
@ -444,12 +431,7 @@ return array(
'MediaQuestion' => $baseDir . '/main/exercice/media_question.class.php',
'MessageManager' => $baseDir . '/main/inc/lib/message.lib.php',
'Model' => $baseDir . '/main/inc/lib/model.lib.php',
'Model\\Course' => $baseDir . '/main/inc/lib/course.class.php',
'Model\\Document' => $baseDir . '/main/inc/lib/document.class.php',
'Model\\ItemProperty' => $baseDir . '/main/inc/lib/item_property.class.php',
'Model\\ItemPropertyRepository' => $baseDir . '/main/inc/lib/item_property.class.php',
'Model\\StudentPublication' => $baseDir . '/main/inc/lib/student_publication.class.php',
'Model\\StudentPublicationRepository' => $baseDir . '/main/inc/lib/student_publication.class.php',
'MultipleAnswer' => $baseDir . '/main/exercice/multiple_answer.class.php',
'MultipleAnswerCombination' => $baseDir . '/main/exercice/multiple_answer_combination.class.php',
'MultipleAnswerCombinationTrueFalse' => $baseDir . '/main/exercice/multiple_answer_combination_true_false.class.php',
@ -486,7 +468,6 @@ return array(
'PGTStorageDB' => $baseDir . '/main/auth/cas/lib/CAS/PGTStorage/pgt-db.php',
'PGTStorageFile' => $baseDir . '/main/auth/cas/lib/CAS/PGTStorage/pgt-file.php',
'PHP_Evaluator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/php_evaluator.cls.php',
'Page' => $baseDir . '/main/inc/lib/page.class.php',
'PageController' => $baseDir . '/main/inc/lib/page.lib.php',
'Page_Cache' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_cache.cls.php',
'Page_Frame_Decorator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_frame_decorator.cls.php',
@ -528,15 +509,11 @@ return array(
'QuizQuestion' => $baseDir . '/main/coursecopy/classes/QuizQuestion.class.php',
'QuizQuestionOption' => $baseDir . '/main/coursecopy/classes/QuizQuestionOption.class.php',
'RSSCache' => $baseDir . '/main/inc/lib/magpierss/rss_cache.inc',
'Redirect' => $baseDir . '/main/inc/lib/redirect.class.php',
'Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/renderer.cls.php',
'Resource' => $baseDir . '/main/coursecopy/classes/Resource.class.php',
'Response' => $baseDir . '/main/inc/lib/response.class.php',
'Result' => $baseDir . '/main/gradebook/lib/be/result.class.php',
'ResultSet' => $baseDir . '/main/inc/lib/result_set.class.php',
'ResultTable' => $baseDir . '/main/gradebook/lib/fe/resulttable.class.php',
'ResultsDataGenerator' => $baseDir . '/main/gradebook/lib/results_data_generator.class.php',
'Rights' => $baseDir . '/main/inc/lib/rights.lib.php',
'S3SoapClient' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeS3.class.php',
'SVG' => $vendorDir . '/mpdf/mpdf/classes/svg.php',
'ScoreDisplay' => $baseDir . '/main/gradebook/lib/scoredisplay.class.php',
@ -684,7 +661,6 @@ return array(
'UniqueAnswerNoOption' => $baseDir . '/main/exercice/unique_answer_no_option.class.php',
'Uri' => $baseDir . '/main/inc/lib/uri.class.php',
'UrlManager' => $baseDir . '/main/inc/lib/urlmanager.lib.php',
'UserApiKeyManager' => $baseDir . '/main/inc/lib/user_api_key_manager.class.php',
'UserDataGenerator' => $baseDir . '/main/gradebook/lib/user_data_generator.class.php',
'UserForm' => $baseDir . '/main/gradebook/lib/fe/userform.class.php',
'UserGroup' => $baseDir . '/main/inc/lib/usergroup.lib.php',

@ -44,6 +44,7 @@ return array(
'Symfony\\Bridge\\Monolog\\' => array($vendorDir . '/symfony/monolog-bridge'),
'Symfony\\Bridge\\Doctrine\\' => array($vendorDir . '/symfony/doctrine-bridge'),
'SwfTools' => array($vendorDir . '/swftools/swftools/src'),
'Sunra\\PhpSimple\\HtmlDomParser' => array($vendorDir . '/sunra/php-simple-html-dom-parser/Src'),
'Silex\\Provider\\' => array($vendorDir . '/silex/web-profiler'),
'SilexOpauth' => array($vendorDir . '/icehero/silex-opauth/src'),
'SilexAssetic' => array($vendorDir . '/mheap/silex-assetic/src'),

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581
class ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
@ -45,14 +45,14 @@ class ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire68de3dbf4a2a3e667c00f4d8391e6581($file);
composerRequireda8df92eadc454c2aaf367aac7d7b7ce($file);
}
return $loader;
}
}
function composerRequire68de3dbf4a2a3e667c00f4d8391e6581($file)
function composerRequireda8df92eadc454c2aaf367aac7d7b7ce($file)
{
require $file;
}

@ -5746,5 +5746,50 @@
"assetic",
"silex"
]
},
{
"name": "sunra/php-simple-html-dom-parser",
"version": "v1.5.0",
"version_normalized": "1.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/sunra/php-simple-html-dom-parser.git",
"reference": "a0b80ace086c7e09085669205e1b3c2c9c7a453c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sunra/php-simple-html-dom-parser/zipball/a0b80ace086c7e09085669205e1b3c2c9c7a453c",
"reference": "a0b80ace086c7e09085669205e1b3c2c9c7a453c",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"time": "2013-05-04 14:32:03",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Sunra\\PhpSimple\\HtmlDomParser": "Src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sunra",
"email": "sunra@yandex.ru",
"homepage": "https://github.com/sunra"
}
],
"description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",
"homepage": "https://github.com/sunra/php-simple-html-dom-parser",
"keywords": [
"dom",
"html",
"parser"
]
}
]

@ -0,0 +1,38 @@
php-simple-html-dom-parser
==========================
Version 1.5
Adaptation for Composer and PSR-0 of:
A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
Require PHP 5+.
Supports invalid HTML.
Find tags on an HTML page with selectors just like jQuery.
Extract contents from HTML in a single line.
http://simplehtmldom.sourceforge.net/
Install
-------
composer.phar require
- package name: "sunra/php-simple-html-dom-parser": "dev-master"
Usage
-----
```php
use Sunra\PhpSimple\HtmlDomParser;
...
$dom = HtmlDomParser::str_get_html( $str );
or
$dom = HtmlDomParser::file_get_html( $file_name );
$elems = $dom->find($elem_name);
...
```

@ -0,0 +1,20 @@
<?php
// say me who add "О╩©" into start of file?
// Becouse of this 3 symbol before <?php - php get error
// i think it Sublime Text
namespace Sunra\PhpSimple;
require 'simplehtmldom_1_5'.DIRECTORY_SEPARATOR.'simple_html_dom.php';
class HtmlDomParser {
static public function file_get_html() {
return call_user_func_array ( '\file_get_html' , func_get_args() );
}
// get html dom from string
static public function str_get_html() {
return call_user_func_array ( '\str_get_html' , func_get_args() );
}
}

@ -0,0 +1,891 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="ctl00_Head1"><title>
FootballScoresLive - Previous Results
</title><meta name="Keywords" content="football,soccer,score,goals,penalty,penalties,red cards,yellow cards,results,england,
english,scotland,scottish,wales,welsh,europe,european,sms,results by sms" /><meta name="Description" content="FootballScoresLive offers continuous updates of scores from football (soccer)
matches in Britain, Europe, North and South America, and Asia, free direct to your web browser,
and by SMS to your mobile." /><link href="page.css" rel="stylesheet" type="text/css" /><link href="news.css" rel="stylesheet" type="text/css" /><link href="results.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
<script type="text/javascript" src="MMfuncs.js"></script>
<script type="text/javascript" src="swfdetect.js"></script>
<script type="text/vbscript" src="swfver.vbs"></script>
<link rel="shortcut icon" href="/favicon.ico" /><style type="text/css">
.atlas__delta { font-family:Lucida Console; }
</style></head>
<body onload="MM_preloadImages('images/buttons/englishNational_hl.jpg','images/buttons/englishLeagues_hl.jpg',
'images/buttons/futureFixtures_hl.jpg','images/buttons/italianLeagues_hl.jpg','images/buttons/leagueTables_hl.jpg','images/buttons/login_hl.jpg','images/buttons/favourites_hl.jpg','images/buttons/personalise_hl.jpg','images/buttons/previousResults_hl.jpg','images/buttons/scottishLeagues_hl.jpg','images/buttons/seasonTicket_hl.jpg','images/buttons/spanishLeagues_hl.jpg','images/buttons/sponsored_hl.jpg','images/buttons/supermarket_hl.jpg','images/buttons/livescores_hl.jpg')"
onunload="MM_callJS('CheckFlash();')">
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<form name="aspnetForm" method="post" action="MatchResults.aspx" id="aspnetForm">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="dB6ayi9LZ+8oLEEG+Bb0EaB7S0yWNAwmwFJYNlmIPIfC1cvZYgBlKWTvoA4O9/nWx6kKCiBPFnSnfWNC5mLsqwKJAqRalzt4zBR7te1bjeJGgN0H2d1aCn3KgK2DLo6jp/xsNAQLvdqugFXdJ+7RvO58WASnJAH4vjnV2vTi6kKfuRGvNvzsfcybchbHQ+T2yUU9pTrLfSRSC6qEw00ANEJLyR8cnnsgTQhOcXFIPwCbFQEljWnQHmV6l+YMt9GeyxuhD7qL+JcVOPkqZ4TROE1TWmVLD8kOwmpEaMwINDlz/veOnNh/HVdabDznCkdFd3yzhpyyx4/mqWqp4GmkbsFyiUvZoKYin/4xf7L1Z0NfMamm3lZZMFpWz8AhmWcL99qa5kcLgjtXMzZvOKn6K/pud0lEVkvl3Kz2jXgzZPxh3qdX4Nx5anjttd6NKyF3wSlfVMk0j8zoZmja8HaqpwZZfSFnn+U7wWO6D9vzZKDJ/nxUbJHqEaLYYz+QD6zWHVfsEi3cZJlit0oOWatl8AjSHKPmFi3oD9jD3K/FiuhYFYkyk07Jpoe/6YvKgeisZaFYDQrqTTVGYul9rQRVRkUc0UVrt7TZJ/d08EXYKhWYRBx2xxQt3Yfbefr45GCComTUGOjml7DVITe9811QIXfgw5GaECa6aBi2hvYSB6gdhFlqrdqi/HK2DTcXFTyN5n749O3MgVJGSQtXP/xsTp3J1t2lOSMlz9hZYwQUDqOpaWZG2Ae8JmzhvdClyw1AxhJolgEGsutAtYhXFc16ihtjYd/JXx47zeBoB8temPCNJwpFmAN3iXV9nhu5RZ6q8hSnpfCBCn756EDnykItEhTStGovLsJG+QdRNsLE56mNtIxFxeAGrwLWJ260+QsRcvimNAERfZtow7Vx/JPMJLfXrvd1G6u0jP/uqJAQPP8WjVUUfAK5yJHi2PzzGTtFDPd7TJenlgzzyzTcPjJKib+W+CRBBboPRnro9659+79nZwYXdbHHDlQiNcBKZfYKohFHSteJRn4/XnUI2MAi+j9a5JfGs7syF7OWjvFCevTrS/toNPaPzM+muJF3/cLQA0kuM/OvaS+9Kj16BCdNfy6mPZMy6pD95xMGomu1adBwKvaTLMmjrt5Kgh5RxGrUf+pl1IoY9u8=" />
<script src="/WebResource.axd?d=OSFApkHgVTFGp_WGnj5w0YyfbDgId8eejj1HHj2udCziBXq1lnucLLMhY2b4ssXravjY6R0n3Xz5xE3pKbfs7VC_WlWODN-9NNOB8qqY6cA1&amp;t=633112977674076250" type="text/javascript"></script>
<script src="/WebResource.axd?d=OSFApkHgVTFGp_WGnj5w0YyfbDgId8eejj1HHj2udCziBXq1lnucLLMhY2b4ssXravjY6R0n3Xz5xE3pKbfs7blAzxonPUmCsga2GgPJUY41&amp;t=633112977674076250" type="text/javascript"></script>
<div>
<table id="Table_01" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" rowspan="2" width="394" height="111" >
<a href="LiveScores.aspx">
<img src="images/fsl_logo.jpg" width="394" height="111" border="0" alt="FootballScoresLive logo" /></a></td>
<td height="81" width="100%" valign="middle" background="images/grass_top.jpg" align="center">
<a id="ctl00_lnkScores2Mobile" title="Click here for Live Scores to your mobile" href="live-premiership-football-scores-via-sms.aspx" style="display:inline-block;"><img title="Click here for Live Scores to your mobile" src="images/scores2mobile.jpg" border="0" /></a>
</td>
<td width="174" height="81" align="center" valign="middle" background="images/grass_top.jpg">
<a href="Register.aspx"><img src="images/btn_reg.gif" border="0" /></a>
</td>
</tr>
<tr style="color: yellow;">
<td width="237" height="30" align="center" valign="middle" background="images/visitors_bg.jpg" class="body12">
<strong>
For <span style="color: red">FREE</span> goals to your mobile</strong>
<a id="ctl00_HyperLink1" class="navlink" href="fixtures.aspx">Click Here</a></td>
<td align="center" valign="middle" bgcolor="#000000" class="body12">
<table width=100% border="0" cellpadding="0" cellspacing="0">
<tr style="color: white;">
<td>
<input type="submit" name="ctl00$LoginView5$btnLogin" value="LogIn" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$LoginView5$btnLogin&quot;, &quot;&quot;, false, &quot;&quot;, &quot;login.aspx&quot;, false, false))" id="ctl00_LoginView5_btnLogin" />
</td>
<td>&nbsp;
</td>
</tr>
</table>
</td>
</tr>
<!--
<tr>
<td height="16" colspan="4" bgcolor="#000000">
&nbsp;|&nbsp;<a href="default.aspx" class="navlink">Home</a>
&nbsp;|&nbsp;<a href="live-premiership-football-scores-via-sms.aspx" class="navlink">SMS Service</a>
&nbsp;|&nbsp;<a href="LiveScores.aspx" class="navlink">Live Scores</a>
&nbsp;|&nbsp;<a href="MatchResults.aspx" class="navlink">Previous Results</a>
&nbsp;|&nbsp;<a href="fixtures.aspx" class="navlink">Future Fixtures</a>&nbsp;|&nbsp;
<a id="ctl00_LoginStatus2" class="navlink" href="javascript:__doPostBack('ctl00$LoginStatus2$ctl02','')">Login</a>&nbsp;|&nbsp;
<a href="login/personal.aspx" class="navlink">Personalise</a>&nbsp;|&nbsp;
<br />
</td>
</tr>
-->
<tr height="100%">
<td width="174" align="center" valign="top" background="images/grass_left.jpg">
<!--
<a href="#" onclick='window.external.AddFavorite(location.href,document.title);' class="navlink">
<img src="images/favourites.jpg" border="0"/></a>
-->
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<a href="#" onclick='window.external.AddFavorite(location.href,document.title);' class="navlink">
<img src="images/buttons/favourites.jpg" border="0" alt="Add this page to your favourites" name="fav" width="165" height="21" onmouseover="MM_swapImage('fav','','images/buttons/favourites_hl.jpg',1)" onmouseout="MM_swapImgRestore()" />
</a>
</td>
</tr>
<tr>
<td><img src="images/buttons/seasonTicket.jpg" border="0" alt="Season Ticket Goal Alerts - coming soon" name="season" width="166" height="22" onmouseover="MM_swapImage('season','','images/buttons/seasonTicket_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td><img src="images/buttons/mobile.jpg" border="0" alt="Mobile Goal Alerts" name="mobile" width="166" height="20" /></td>
</tr>
<tr>
<td><a href="live-premiership-football-scores-via-sms.aspx">
<img src="images/buttons/englishLeagues.jpg" alt="English Leagues" name="engLg" width="166" height="19" border="0" onmouseover="MM_swapImage('engLg','','images/buttons/englishLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td><img src="images/buttons/englishNational.jpg" border="0" alt="English National Team - coming soon" name="engNat" width="166" height="18" onmouseover="MM_swapImage('engNat','','images/buttons/englishNational_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td>
<a href="live-scottish-premier-league-football-scores-via-sms.aspx">
<img src="images/buttons/scottishLeagues.jpg" border="0" alt="Scottish Leagues" name="scotLg" width="166" height="18" onmouseover="MM_swapImage('scotLg','','images/buttons/scottishLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td>
<a href="live-spain-football-scores-via-sms.aspx">
<img src="images/buttons/spanishLeagues.jpg" border="0" alt="Spanish Leagues" name="spanLg" width="166" height="18" onmouseover="MM_swapImage('spanLg','','images/buttons/spanishLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td>
<a href="live-italy-football-scores-via-sms.aspx">
<img src="images/buttons/italianLeagues.jpg" border="0" alt="Italian Leagues" name="italLg" width="166" height="18" onmouseover="MM_swapImage('italLg','','images/buttons/italianLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td><a href="LiveScores.aspx"><img src="images/buttons/livescores.jpg" border="0" alt="Live Scores" name="world" width="166" height="20" onmouseover="MM_swapImage('world','','images/buttons/livescores_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td><img src="images/buttons/supermarket.jpg" border="0" alt="Football Supermarket - coming soon" name="super" width="166" height="20" onmouseover="MM_swapImage('super','','images/buttons/supermarket_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td><a href="MatchResults.aspx"><img src="images/buttons/previousResults.jpg" border="0" alt="Previous Results" name="prev" width="166" height="20" onmouseover="MM_swapImage('prev','','images/buttons/previousResults_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td><a href="fixtures.aspx"><img src="images/buttons/futureFixtures.jpg" border="0" alt="Future Fixtures" name="future" width="166" height="20" onmouseover="MM_swapImage('future','','images/buttons/futureFixtures_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
<tr>
<td><img src="images/buttons/leagueTables.jpg" border="0" alt="League Tables - coming soon" name="lgTbl" width="166" height="20" onmouseover="MM_swapImage('lgTbl','','images/buttons/leagueTables_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td><img src="images/buttons/sponsored.jpg" border="0" alt="Sponsored Links - coming soon" name="spons" width="166" height="20" onmouseover="MM_swapImage('spons','','images/buttons/sponsored_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><img src="images/buttons/personalise.jpg" border="0" alt="Personalise" name="pers" width="166" height="20" onmouseover="MM_swapImage('pers','','images/buttons/personalise_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td>
<input id="ctl00_LoginStatus1" type="image" name="ctl00$LoginStatus1$ctl03" class="navlink" src="images/buttons/login.jpg" alt="Login" border="0" />
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
<a href="fixtures.aspx">
<img src="images/fsl_phone_static.jpg" width="130" height="238" border="0" />
</a>
<div id="ctl00_FixtureSelectPanel">
<table border="0" cellpadding="0" cellspacing="0">
<tr style="background-color:Black; color:Green">
<td colspan="2">
<img id="ctl00_Image1" src="images/fixtures.jpg" border="0" /></td>
</tr>
<tr style="background-color:White">
<td align="left">
<select name="ctl00$FixtureDropDown" id="ctl00_FixtureDropDown" title="Choose the date you want to see the fixtures" class="body">
<option value="18/12/2008 00:00:00">18/12/2008</option>
<option value="19/12/2008 00:00:00">19/12/2008</option>
<option value="20/12/2008 00:00:00">20/12/2008</option>
<option value="21/12/2008 00:00:00">21/12/2008</option>
<option value="22/12/2008 00:00:00">22/12/2008</option>
<option value="23/12/2008 00:00:00">23/12/2008</option>
<option value="26/12/2008 00:00:00">26/12/2008</option>
<option value="27/12/2008 00:00:00">27/12/2008</option>
<option value="28/12/2008 00:00:00">28/12/2008</option>
<option value="29/12/2008 00:00:00">29/12/2008</option>
<option value="30/12/2008 00:00:00">30/12/2008</option>
<option value="01/01/2009 00:00:00">01/01/2009</option>
<option value="02/01/2009 00:00:00">02/01/2009</option>
</select>
</td>
<td align="right">
<input type="image" name="ctl00$FixtureButton" id="ctl00_FixtureButton" title="Click to see the fixtures on your chosen date" src="images/go.gif" align="absmiddle" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$FixtureButton&quot;, &quot;&quot;, false, &quot;&quot;, &quot;fixtures.aspx&quot;, false, false))" border="0" />
</td>
</tr>
</table>
</div>
<br />
<div style="text-align: center">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td>
<a href="live-premiership-football-scores-via-sms.aspx">
<img src="images/flags2/england.jpg" border="0" alt="English Leagues goal alerts by SMS" /></a></td>
<td>
<a href="live-scottish-premier-league-football-scores-via-sms.aspx">
<img src="images/flags2/scotland.jpg" border="0" alt="Scottish Leagues goal alerts by SMS" /></a></td>
<td>
<a href="live-spain-football-scores-via-sms.aspx">
<img src="images/flags2/Spain.jpg" border="0" alt="Spanish Leagues goal alerts by SMS" /></a></td>
<td>
<a href="live-italy-football-scores-via-sms.aspx">
<img src="images/flags2/Italy.jpg" border="0" alt="Italian Leagues goal alerts by SMS" /></a></td>
</tr>
</table>
</div>
<br />
<img src="images/status.gif" width="110" height="127" /><br />
<br />
<img src="images/events.gif" width="110" height="115" /><br />
</td>
<td width="100%" colspan="2" align="center" valign="top">
<div id="ctl00_ContentPlaceHolder1_UpdatePanel1">
<h1>Historical Football Archive - Updated Daily!</h1>
<br />
<p class="body12">Missed the details of your football club's latest performance?
Whether you support Manchester United or Cambridge United, Premiership club or Conference club,
you will find it all here, with our fantastic soccer library of results over the last two weeks.
These pages contain the history & detailed results package for every football game from around the world
from the last 14 match days, including not only every goal scored, but, game results, names of goal scorer,
match results, red cards and plenty more! This service is automatically updated every 24 hours,
simply select a date from the drop down menu :-
</p>
<select name="ctl00$ContentPlaceHolder1$DropDownList1" id="ctl00_ContentPlaceHolder1_DropDownList1">
<option selected="selected" value="17/12/2008 00:00:00">Wed 17/12/2008</option>
<option value="16/12/2008 00:00:00">Tue 16/12/2008</option>
<option value="15/12/2008 00:00:00">Mon 15/12/2008</option>
<option value="14/12/2008 00:00:00">Sun 14/12/2008</option>
<option value="13/12/2008 00:00:00">Sat 13/12/2008</option>
<option value="12/12/2008 00:00:00">Fri 12/12/2008</option>
<option value="11/12/2008 00:00:00">Thu 11/12/2008</option>
<option value="10/12/2008 00:00:00">Wed 10/12/2008</option>
<option value="09/12/2008 00:00:00">Tue 09/12/2008</option>
<option value="08/12/2008 00:00:00">Mon 08/12/2008</option>
<option value="07/12/2008 00:00:00">Sun 07/12/2008</option>
<option value="06/12/2008 00:00:00">Sat 06/12/2008</option>
<option value="05/12/2008 00:00:00">Fri 05/12/2008</option>
<option value="04/12/2008 00:00:00">Thu 04/12/2008</option>
</select>
<br /><br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl00_CompGames1_lblCompName">&nbsp;SCOTLAND - DIVISION 2</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl00_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
19:45
</td><td>Pst </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">STRANRAER</td><td align="right">0</td><td align="left">0</td><td align="left">PETERHEAD</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
&nbsp;
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_CompGames1_lblCompName">&nbsp;ENGLAND - FA TROPHY - FIRST ROUND</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">SWINDON SUPERMARINE</td><td align="right">1</td><td align="left">0</td><td align="left">EASTBOURNE BOROUGH</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Replayed if draw.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>EDENBOROUGH</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">74<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">EDENBOROUGH</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl02_CompGames1_lblCompName">&nbsp;EUROPE (UEFA) - UEFA CUP - GROUP STAGE</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl02_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">AC MILAN</td><td align="right">2</td><td align="left">2</td><td align="left">VfL WOLFSBURG</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>17</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>AMBROSINI</td></tr><tr><td>56</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>PATO</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>55</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ZACCARDO</td></tr><tr><td>81</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SAGLIK</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">81<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">SAGLIK</a>
</td>
</tr><tr class="row_alt">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td bgcolor="Red">
1
</td><td>
&nbsp;
</td><td align="right">AJAX</td><td align="right">2</td><td align="left">2</td><td align="left">SLAVIA PRAHA</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>4</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>VERTONGHEN</td></tr><tr><td>90</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball-pen.gif\' alt=\'penalty\'></td><td nowrap=nowrap>SUAREZ</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>13</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>CERNY</td></tr><tr><td>41</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>JAROLIM</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">90<img align="top" width="17" height="16" border="0" src="images/ball-pen.gif" alt="penalty">SUAREZ</a>
</td>
</tr><tr class="row">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">CLUB BRUGGE</td><td align="right">0</td><td align="left">1</td><td align="left">FC COPENHAGEN</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>58</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SANTIN</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">58<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">SANTIN</a>
</td>
</tr><tr class="row_alt">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">DEP. LA CORUNA</td><td align="right">1</td><td align="left">0</td><td align="left">NANCY</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BODIPO</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">74<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">BODIPO</a>
</td>
</tr><tr class="row">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">FEYENOORD</td><td align="right">0</td><td align="left">1</td><td align="left">LECH POZNAN</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>26</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>DJURDJEVIC</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">26<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">DJURDJEVIC</a>
</td>
</tr><tr class="row_alt">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">HAMBURGER SV</td><td align="right">3</td><td align="left">1</td><td align="left">ASTON VILLA</td><td bgcolor="Red">
1
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>18</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>PETRIC</td></tr><tr><td>30</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>OLIC</td></tr><tr><td>57</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>OLIC</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>82</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>DELFOUNESO</td></tr><tr><td>84</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/redcard.gif\' alt=\'red card\'></td><td nowrap=nowrap>SIDWELL</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">84<img align="top" width="17" height="16" border="0" src="images/redcard.gif" alt="red card">SIDWELL</a>
</td>
</tr><tr class="row">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">PORTSMOUTH</td><td align="right">3</td><td align="left">0</td><td align="left">HEERENVEEN</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>40</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>CROUCH</td></tr><tr><td>42</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>CROUCH</td></tr><tr><td>90</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>HREIDARSSON</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">90<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">HREIDARSSON</a>
</td>
</tr><tr class="row_alt">
<td>
19:45
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">ST ETIENNE</td><td align="right">2</td><td align="left">2</td><td align="left">VALENCIA</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>29</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ILAN</td></tr><tr><td>44</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ILAN</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>33</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>MORIENTES</td></tr><tr><td>72</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ZIGIC</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">72<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">ZIGIC</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl03_CompGames1_lblCompName">&nbsp;INTERNATIONAL TOURNAMENTS - OMAN FOUR NATIONS TOUR</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl03_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
14:00
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">OMAN</td><td align="right">3</td><td align="left">1</td><td align="left">CHINA</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>47</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BASHEER</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SALEH</td></tr><tr><td>84</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SALEH</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>53</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BO</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">84<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">SALEH</a>
</td>
</tr><tr class="row_alt">
<td>
16:30
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">ECUADOR</td><td align="right">1</td><td align="left">0</td><td align="left">IRAN</td><td bgcolor="Red">
1
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>55</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>MARTINEZ</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>90</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/redcard.gif\' alt=\'red card\'></td><td nowrap=nowrap>NEJAD</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">90<img align="top" width="17" height="16" border="0" src="images/redcard.gif" alt="red card">NEJAD</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl04_CompGames1_lblCompName">&nbsp;ITALY - FA CUP - ROUND 16</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl04_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
16:00
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">FIORENTINA</td><td align="right">0</td><td align="left">1</td><td align="left">TORINO</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>19</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BIANCHI</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">19<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">BIANCHI</a>
</td>
</tr><tr class="row_alt">
<td>
20:00
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">ROMA</td><td align="right">2</td><td align="left">0</td><td align="left">BOLOGNA</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>82</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>VUCINIC</td></tr><tr><td>86</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>VUCINIC</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">86<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">VUCINIC</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl05_CompGames1_lblCompName">&nbsp;ITALY - SERIE C1A</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl05_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
13:30
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">PRO SESTO</td><td align="right">0</td><td align="left">0</td><td align="left">LECCO</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
&nbsp;
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl06_CompGames1_lblCompName">&nbsp;ITALY - SERIE C2A</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl06_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
13:30
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">MEZZOCORONA</td><td align="right">1</td><td align="left">3</td><td align="left">SAMBONIFACESE</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>55</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>48</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr><tr><td>66</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">74<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">&nbsp;</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl07_CompGames1_lblCompName">&nbsp;SCOTLAND - FA CUP - THIRD ROUND</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl07_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
13:30
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">LOCHEE UTD</td><td align="right">1</td><td align="left">1</td><td align="left">AYR UTD</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Replayed if draw.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>86</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>HAGAN</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>60</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>WILLIAMS</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">86<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">HAGAN</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align: left" class="header">
<span id="ctl00_ContentPlaceHolder1_Repeater1_ctl08_CompGames1_lblCompName">&nbsp;WORLD (FIFA) - FIFA CLUB WORLD CHAMPIONSHIP - SEMI</span></td>
</tr>
<tr>
<td>
<div>
<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl08_CompGames1_GridView1" width="100%">
<tr class="header" align="left">
<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10"> </th><th align="left" scope="col" width="10"> </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
</tr><tr class="row">
<td>
10:30
</td><td>FT </td><td>-</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td align="right">PACHUCA (MEX)</td><td align="right">0</td><td align="left">2</td><td align="left">LIGA D.U. QUITO(ECU)</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
&nbsp;
</td><td>
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Playing at Tokyo, Japan. Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
</td><td align="left">
<a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>4</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BIELER</td></tr><tr><td>26</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BOLANOS</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">26<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">BOLANOS</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
</div>
<table border="0" cellpadding="5" cellspacing="0" style="width: 100%; height: 100%">
<tr class="newslinkspace">
<td style="width: 100%">
View complete <a href="ResultsArchive.aspx" class="newslink">archive of FootballScoresLive.com Match Results</a>
</td>
</tr>
</table>
</td>
<td width="125" align="right" valign="top">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="120" height="600">
<param name="movie" value="http://www.footballscoreslive.com/images/fslSMSNew.swf" />
<param name="quality" value="high" />
<embed src="http://www.footballscoreslive.com/images/fslSMSNew.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="120" height="600"></embed>
</object>
<script type="text/javascript"><!--
google_ad_client = "pub-1398285862595543";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
<tr>
<td>
<img src="images/spacer.gif" width="174" height="1" alt="" /></td>
<td>
<img src="images/spacer.gif" width="220" height="1" alt="" /></td>
<td>
<img src="images/spacer.gif" width="281" height="1" alt="" /></td>
<td>
<img src="images/spacer.gif" width="125" height="1" alt="" /></td>
</tr>
<tr>
<td height="16" colspan="4" bgcolor="#000000">
&nbsp;|&nbsp;
<a class="navlink" href="disclaimer.aspx">Disclaimer</a>&nbsp;|&nbsp;
<a class="navlink" href="privacy.aspx">Privacy</a>&nbsp;|&nbsp;
<a href="aboutus.aspx" class="navlink">About Us</a>&nbsp;|&nbsp;
<a href="NewsArchive.aspx" class="navlink">News Archive</a>&nbsp;|&nbsp;
</td>
</tr>
</table>
</div>
<input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="Xh65BZM36Ruds-iXM2l7LB-dXtc__8RpYzxQLE4V_YQ1" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="2ybQ+H9cPYUzPPi/5ComPVhU+jAYPdxVR+fOu2ZZbs2RxuAweOrbEg/qP5f+1OYLQI+oQJb98YQDTTMw+x86m7Np3/NYQHDjzX76RjJfW9nS6SnJVUi1nLHSh9c7wgfVB7UNjywCsU0hiMY1IUsYkR/rClTQE4j3Q4a4ub3Cqrn+b7fY3itatSObxb3L0Pq9E9vx/RpYI3jhA2RPCnO1WEQF2kEBAba5qqLwESWolSSdLqs5DRta8kholg0zw5EA5/R9+XiPqWwbk4n/TnTtdMwQq2iExD4eyjsLsE7bWnw=" />
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<pageRequestManager id="_PageRequestManager" updatePanelIDs="ctl00$ContentPlaceHolder1$UpdatePanel1" asyncPostbackControlIDs="ctl00_ContentPlaceHolder1_DropDownList1" scriptManagerID="ctl00$ContentPlaceHolder1$ScriptManager1" form="aspnetForm" />
</components>
</page></script>
<script type="text/javascript">
</script>
</form>
</body>
</html>

@ -0,0 +1,144 @@
<?php
error_reporting(E_ALL);
include_once('../simple_html_dom.php');
$html = file_get_html('google.htm');
//$html = file_get_html('youtube.htm');
//$html = file_get_html('Product.ibatis.xml');
$lang = '';
$l=$html->find('html', 0);
if ($l!==null)
$lang = $l->lang;
if ($lang!='')
$lang = 'lang="'.$lang.'"';
$charset = $html->find('meta[http-equiv*=content-type]', 0);
$target = array();
$query = '';
if (isset($_REQUEST['query'])) {
$query = $_REQUEST['query'];
$target = $html->find($query);
}
function stat_dom($dom) {
$count_text = 0;
$count_comm = 0;
$count_elem = 0;
$count_tag_end = 0;
$count_unknown = 0;
foreach($dom->nodes as $n) {
if ($n->nodetype==HDOM_TYPE_TEXT)
++$count_text;
if ($n->nodetype==HDOM_TYPE_COMMENT)
++$count_comm;
if ($n->nodetype==HDOM_TYPE_ELEMENT)
++$count_elem;
if ($n->nodetype==HDOM_TYPE_ENDTAG)
++$count_tag_end;
if ($n->nodetype==HDOM_TYPE_UNKNOWN)
++$count_unknown;
}
echo 'Total: '. count($dom->nodes).
', Text: '.$count_text.
', Commnet: '.$count_comm.
', Tag: '.$count_elem.
', End Tag: '.$count_tag_end.
', Unknown: '.$count_unknown;
}
function dump_my_html_tree($node, $show_attr=true, $deep=0, $last=true) {
$count = count($node->nodes);
if ($count>0) {
if($last)
echo '<li class="expandable lastExpandable"><div class="hitarea expandable-hitarea lastExpandable-hitarea"></div>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
else
echo '<li class="expandable"><div class="hitarea expandable-hitarea"></div>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
}
else {
$laststr = ($last===false) ? '' : ' class="last"';
echo '<li'.$laststr.'>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
}
if ($show_attr) {
foreach($node->attr as $k=>$v) {
echo ' '.htmlspecialchars($k).'="<span class="attr">'.htmlspecialchars($node->$k).'</span>"';
}
}
echo '&gt;';
if ($node->tag==='text' || $node->tag==='comment') {
echo htmlspecialchars($node->innertext);
return;
}
if ($count>0) echo "\n<ul style=\"display: none;\">\n";
$i=0;
foreach($node->nodes as $c) {
$last = (++$i==$count) ? true : false;
dump_my_html_tree($c, $show_attr, $deep+1, $last);
}
if ($count>0)
echo "</ul>\n";
//if ($count>0) echo '&lt;/<span class="attr">'.htmlspecialchars($node->tag).'</span>&gt;';
echo "</li>\n";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html <?=$lang?>>
<head>
<?
if ($lang!='')
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>';
else if ($charset)
echo $charset;
else
echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>';
?>
<title>Simple HTML DOM Query Test</title>
<link rel="stylesheet" href="js/jquery.treeview.css" />
<link rel="stylesheet" href="js/screen.css" />
<style>
.tag { color: blue; }
.attr { color: #990033; }
</style>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.treeview.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#html_tree").treeview({
control:"#sidetreecontrol",
collapsed: true,
prerendered: true
});
});
</script>
</head>
<body>
<div id="main">
<h4>Simple HTML DOM Test</h4>
<form name="form1" method="post" action="">
find: <input name="query" type="text" size="60" maxlength="60" value="<?=htmlspecialchars($query)?>">
<input type="submit" name="Submit" value="Go">
</form>
<br>
HTML STAT (<?stat_dom($html);?>)<br>
<br>
<div id="sidetreecontrol"><a href="?#">Collapse All</a> | <a href="?#">Expand All</a></div><br>
<ul class="treeview" id="html_tree">
<?
ob_start();
foreach($target as $e)
dump_my_html_tree($e, true);
ob_end_flush();
?>
</ul>
</div>
</body></html>

@ -0,0 +1,68 @@
.treeview, .treeview ul {
padding: 0;
margin: 0;
list-style: none;
}
.treeview ul {
background-color: white;
margin-top: 4px;
}
.treeview .hitarea {
background: url(images/treeview-default.gif) -64px -25px no-repeat;
height: 16px;
width: 16px;
margin-left: -16px;
float: left;
cursor: pointer;
}
/* fix for IE6 */
* html .hitarea {
display: inline;
float:none;
}
.treeview li {
margin: 0;
padding: 3px 0pt 3px 16px;
}
.treeview a.selected {
background-color: #eee;
}
#treecontrol { margin: 1em 0; display: none; }
.treeview .hover { color: red; cursor: pointer; }
.treeview li { background: url(images/treeview-default-line.gif) 0 0 no-repeat; }
.treeview li.collapsable, .treeview li.expandable { background-position: 0 -176px; }
.treeview .expandable-hitarea { background-position: -80px -3px; }
.treeview li.last { background-position: 0 -1766px }
.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); }
.treeview li.lastCollapsable { background-position: 0 -111px }
.treeview li.lastExpandable { background-position: -32px -67px }
.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; }
.treeview-red li { background-image: url(images/treeview-red-line.gif); }
.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); }
.treeview-black li { background-image: url(images/treeview-black-line.gif); }
.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); }
.treeview-gray li { background-image: url(images/treeview-gray-line.gif); }
.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); }
.treeview-famfamfam li { background-image: url(images/treeview-famfamfam-line.gif); }
.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); }
.filetree li { padding: 3px 0 2px 16px; }
.filetree span.folder, .filetree span.file { padding: 1px 0 1px 16px; display: block; }
.filetree span.folder { background: url(images/folder.gif) 0 0 no-repeat; }
.filetree li.expandable span.folder { background: url(images/folder-closed.gif) 0 0 no-repeat; }
.filetree span.file { background: url(images/file.gif) 0 0 no-repeat; }

@ -0,0 +1,251 @@
/*
* Treeview 1.4 - jQuery plugin to hide and show branches of a tree
*
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
* http://docs.jquery.com/Plugins/Treeview
*
* Copyright (c) 2007 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
*
*/
;(function($) {
$.extend($.fn, {
swapClass: function(c1, c2) {
var c1Elements = this.filter('.' + c1);
this.filter('.' + c2).removeClass(c2).addClass(c1);
c1Elements.removeClass(c1).addClass(c2);
return this;
},
replaceClass: function(c1, c2) {
return this.filter('.' + c1).removeClass(c1).addClass(c2).end();
},
hoverClass: function(className) {
className = className || "hover";
return this.hover(function() {
$(this).addClass(className);
}, function() {
$(this).removeClass(className);
});
},
heightToggle: function(animated, callback) {
animated ?
this.animate({ height: "toggle" }, animated, callback) :
this.each(function(){
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
if(callback)
callback.apply(this, arguments);
});
},
heightHide: function(animated, callback) {
if (animated) {
this.animate({ height: "hide" }, animated, callback);
} else {
this.hide();
if (callback)
this.each(callback);
}
},
prepareBranches: function(settings) {
if (!settings.prerendered) {
// mark last tree items
this.filter(":last-child:not(ul)").addClass(CLASSES.last);
// collapse whole tree, or only those marked as closed, anyway except those marked as open
this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
}
// return all items with sublists
return this.filter(":has(>ul)");
},
applyClasses: function(settings, toggler) {
this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
toggler.apply($(this).next());
}).add( $("a", this) ).hoverClass();
if (!settings.prerendered) {
// handle closed ones first
this.filter(":has(>ul:hidden)")
.addClass(CLASSES.expandable)
.replaceClass(CLASSES.last, CLASSES.lastExpandable);
// handle open ones
this.not(":has(>ul:hidden)")
.addClass(CLASSES.collapsable)
.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
// create hitarea
this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea).each(function() {
var classes = "";
$.each($(this).parent().attr("class").split(" "), function() {
classes += this + "-hitarea ";
});
$(this).addClass( classes );
});
}
// apply event to hitarea
this.find("div." + CLASSES.hitarea).click( toggler );
},
treeview: function(settings) {
settings = $.extend({
cookieId: "treeview"
}, settings);
if (settings.add) {
return this.trigger("add", [settings.add]);
}
if ( settings.toggle ) {
var callback = settings.toggle;
settings.toggle = function() {
return callback.apply($(this).parent()[0], arguments);
};
}
// factory for treecontroller
function treeController(tree, control) {
// factory for click handlers
function handler(filter) {
return function() {
// reuse toggle event handler, applying the elements to toggle
// start searching for all hitareas
toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
// for plain toggle, no filter is provided, otherwise we need to check the parent element
return filter ? $(this).parent("." + filter).length : true;
}) );
return false;
};
}
// click on first element to collapse tree
$("a:eq(0)", control).click( handler(CLASSES.collapsable) );
// click on second to expand tree
$("a:eq(1)", control).click( handler(CLASSES.expandable) );
// click on third to toggle tree
$("a:eq(2)", control).click( handler() );
}
// handle toggle event
function toggler() {
$(this)
.parent()
// swap classes for hitarea
.find(">.hitarea")
.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
.end()
// swap classes for parent li
.swapClass( CLASSES.collapsable, CLASSES.expandable )
.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
// find child lists
.find( ">ul" )
// toggle them
.heightToggle( settings.animated, settings.toggle );
if ( settings.unique ) {
$(this).parent()
.siblings()
// swap classes for hitarea
.find(">.hitarea")
.replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
.end()
.replaceClass( CLASSES.collapsable, CLASSES.expandable )
.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
.find( ">ul" )
.heightHide( settings.animated, settings.toggle );
}
}
function serialize() {
function binary(arg) {
return arg ? 1 : 0;
}
var data = [];
branches.each(function(i, e) {
data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
});
$.cookie(settings.cookieId, data.join("") );
}
function deserialize() {
var stored = $.cookie(settings.cookieId);
if ( stored ) {
var data = stored.split("");
branches.each(function(i, e) {
$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
});
}
}
// add treeview class to activate styles
this.addClass("treeview");
// prepare branches and find all tree items with child lists
var branches = this.find("li").prepareBranches(settings);
switch(settings.persist) {
case "cookie":
var toggleCallback = settings.toggle;
settings.toggle = function() {
serialize();
if (toggleCallback) {
toggleCallback.apply(this, arguments);
}
};
deserialize();
break;
case "location":
var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
if ( current.length ) {
current.addClass("selected").parents("ul, li").add( current.next() ).show();
}
break;
}
branches.applyClasses(settings, toggler);
// if control option is set, create the treecontroller and show it
if ( settings.control ) {
treeController(this, settings.control);
$(settings.control).show();
}
return this.bind("add", function(event, branches) {
$(branches).prev()
.removeClass(CLASSES.last)
.removeClass(CLASSES.lastCollapsable)
.removeClass(CLASSES.lastExpandable)
.find(">.hitarea")
.removeClass(CLASSES.lastCollapsableHitarea)
.removeClass(CLASSES.lastExpandableHitarea);
$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
});
}
});
// classes used by the plugin
// need to be styled via external stylesheet, see first example
var CLASSES = $.fn.treeview.classes = {
open: "open",
closed: "closed",
expandable: "expandable",
expandableHitarea: "expandable-hitarea",
lastExpandableHitarea: "lastExpandable-hitarea",
collapsable: "collapsable",
collapsableHitarea: "collapsable-hitarea",
lastCollapsableHitarea: "lastCollapsable-hitarea",
lastCollapsable: "lastCollapsable",
lastExpandable: "lastExpandable",
last: "last",
hitarea: "hitarea"
};
// provide backwards compability
$.fn.Treeview = $.fn.treeview;
})(jQuery);

@ -0,0 +1,24 @@
html, body {height:100%; margin: 0; padding: 0; }
html>body {
font-size: 16px;
font-size: 68.75%;
} /* Reset Base Font Size */
body {
font-family: Verdana, helvetica, arial, sans-serif;
font-size: 68.75%;
background: #fff;
color: #333;
}
h1, h2 { font-family: 'trebuchet ms', verdana, arial; padding: 10px; margin: 0 }
h1 { font-size: large }
#banner { padding: 15px; background-color: #06b; color: white; font-size: large; border-bottom: 1px solid #ccc;
background: url(bg.gif) repeat-x; text-align: center }
#banner a { color: white; }
#main { padding: 1em; }
a img { border: none; }

@ -0,0 +1,109 @@
#$Rev: 194 $
[Updates - add some ability to insert and create nodes.]
[1: add ability to search the "noise" array]
[PHP Simple HTML Dom version 1.5 released.]
1: Memory leak fixed!
2: Added support for detecting the source html character set. This is used to convert characters when plaintext is requested.
3: Other little fixes and features, too numerous to categorize.
[On going]
1. Error of "file_get_contents()" will be thrown as an exception.
2. Add flag: LOCK_EX while calling "file_put_contents()".
3. Fix the typo of "token_blank_t".
[PHP Simple HTML DOM Parser v1.11 is released]
1. Supports xpath generated from Firebug.
2. New method "dump" of "simple_html_dom_node".
3. New attribute "xmltext" of "simple_html_dom_node".
4. remove preg_quote on selector match function: [attribute*=value];
5. Element "Comment" will treat as children.
6. Fixed the problem with <pre>.
7. Fixed bug #2207477 (does not load some pages properly).
8. Fixed bug #2315853 (Error with character after < sign).
[PHP Simple HTML DOM Parser v1.10 is released]
1. Negative indexes supports of "find" method, thanks for Vadim Voituk.
2. Constructor with automatically load contents either text or file/url, thanks for Antcs.
3. Fully supports wildcard in selectors.
4. Fixed bug of confusing by the < symbol inside the text.
5. Fixed bug of dash in selectors.
6. Fixed bug of <nobr>.
7. Fixed bug #2155883 (Nested List Parses Incorrectly).
8. Fixed bug #2155113 (error with unclosed html tags).
[PHP Simple HTML DOM Parser v1.00 is released]
1. New method "getAllAttributes" of "simple_html_dom_node".
2. Fix the bug of selector in some critical conditions.
3. Fix the bug of striping php tags.
4. Fix the bug of remove_noise().
5. Fix the bug of noise in attributes.
6. Supports full javascript string in selector: $e->find("a[onclick=alert('hello')]").
7. Change selector "*=" to case-insentive.
[PHP Simple HTML DOM Parser v0.99 is released]
1. Performance turning (boost 10%).
2. Memory requirement reduce 25%.
3. Change function name from "file_get_dom()" to "file_get_html()".
4. Change function name from "str_get_dom()" to "str_get_html()".
5. Fixed bug #2011286 (Error with unclosed html tags).
6. Fixed bug #2012551 (Error parsing divs).
7. Fixed bug #2020924 (Error for missed tag.).
8. Fixed bug (problem with <body> tag's innertext).
[PHP Simple HTML DOM Parser v0.98 is released]
1. Performance turning (boost 20%).
2. Supports "multiple class" selector feature: <div class="a b c"></div>.
3. New "callback function" feature.
4. New "multiple selectors" feature: $dom->find('p,a,b');
5. New examples.
6. Supports extract contents from HTML features: $dom->plaintext;
7. Fix the bug of $dom->clear().
8. Fix the bug of text nodes' innertext.
9. Fix the bug of comment nodes' innertext.
10. Fix the bug of decendent selector with optional tags.
11. Change simple_html_dom_node method name from "text()" to "makeup()".
[PHP Simple HTML DOM Parser v0.97 is released]
1. Important!! file and class name changed (html_dom_parser->simple_html_dom)!
2. Important!! ($dom->save_file) will not support anymore.
3. New node type "comment" (eg. $dom->find('comment')).
4. Add self-closing tags: 'base', 'spacer'.
5. Fix the bug of outertext (th).
6. Fix the bug of regular expression escaping chars ($dom->find).
7. Fix the bug while line-breaker and "\t" in tags.
8. Remove example "example_customize_parser.php".
9. New example "simple_html_dom_utility.php".
[PHP Simple HTML DOM Parser v0.96 is released]
1. (Request #1936000) New DOM operations(first_child, last_child, next_sibling, previous_sibling).
2. New method to remove attribute.
3. Add the solution while server behind proxy in FAQ (Thanks to Yousuke Shaggy).
4. Add traverse section in manual.
5. Now file_get_dom supports full file_get_contents parameters.
6. Fix the bug of self-closing tags in the end of file.
7. Fix the bug of blanks in the end of tag.
8. Add Reference section in manual.
#. Fix some typo of testcase.
[PHP Simple HTML DOM Parser v0.95 is released]
1. New attribute filters (Thanks to Yousuke Kumakura).
2. Fix the bug of optional-closing tags.
3. Fix the bug of parsing the line break next to the tag's name.
4. Supports tag name with namespace.
#. Refine structure of testcase.
[PHP Simple HTML DOM Parser v0.94 is released]
1. Stop infinity loop while tthe source content is BAD HTML.
2. Fix the bug of adding new attributes to self closing tags.
3. Fix the bug of customize parser without $dom->remove_noise();
4. Add FAQ section in manual.

@ -0,0 +1,54 @@
<?php
// example of how to use advanced selector features
include('../simple_html_dom.php');
// -----------------------------------------------------------------------------
// descendant selector
$str = <<<HTML
<div>
<div>
<div class="foo bar">ok</div>
</div>
</div>
HTML;
$html = str_get_html($str);
echo $html->find('div div div', 0)->innertext . '<br>'; // result: "ok"
// -----------------------------------------------------------------------------
// nested selector
$str = <<<HTML
<ul id="ul1">
<li>item:<span>1</span></li>
<li>item:<span>2</span></li>
</ul>
<ul id="ul2">
<li>item:<span>3</span></li>
<li>item:<span>4</span></li>
</ul>
HTML;
$html = str_get_html($str);
foreach($html->find('ul') as $ul) {
foreach($ul->find('li') as $li)
echo $li->innertext . '<br>';
}
// -----------------------------------------------------------------------------
// parsing checkbox
$str = <<<HTML
<form name="form1" method="post" action="">
<input type="checkbox" name="checkbox1" value="checkbox1" checked>item1<br>
<input type="checkbox" name="checkbox2" value="checkbox2">item2<br>
<input type="checkbox" name="checkbox3" value="checkbox3" checked>item3<br>
</form>
HTML;
$html = str_get_html($str);
foreach($html->find('input[type=checkbox]') as $checkbox) {
if ($checkbox->checked)
echo $checkbox->name . ' is checked<br>';
else
echo $checkbox->name . ' is not checked<br>';
}
?>

@ -0,0 +1,37 @@
<?php
// example of how to use basic selector to retrieve HTML contents
include('../simple_html_dom.php');
// get DOM from URL or file
$html = file_get_html('http://www.google.com/');
// find all link
foreach($html->find('a') as $e)
echo $e->href . '<br>';
// find all image
foreach($html->find('img') as $e)
echo $e->src . '<br>';
// find all image with full tag
foreach($html->find('img') as $e)
echo $e->outertext . '<br>';
// find all div tags with id=gbar
foreach($html->find('div#gbar') as $e)
echo $e->innertext . '<br>';
// find all span tags with class=gb1
foreach($html->find('span.gb1') as $e)
echo $e->outertext . '<br>';
// find all td tags with attribite align=center
foreach($html->find('td[align=center]') as $e)
echo $e->innertext . '<br>';
// extract text from table
echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>';
// extract text from HTML
echo $html->plaintext;
?>

@ -0,0 +1,28 @@
<?php
include_once('../simple_html_dom.php');
// 1. Write a function with parameter "$element"
function my_callback($element) {
if ($element->tag=='input')
$element->outertext = 'input';
if ($element->tag=='img')
$element->outertext = 'img';
if ($element->tag=='a')
$element->outertext = 'a';
}
// 2. create HTML Dom
$html = file_get_html('http://www.google.com/');
// 3. Register the callback function with it's function name
$html->set_callback('my_callback');
// 4. Callback function will be invoked while dumping
echo $html;
?>

@ -0,0 +1,5 @@
<?php
include_once('../simple_html_dom.php');
echo file_get_html('http://www.google.com/')->plaintext;
?>

@ -0,0 +1,18 @@
<?php
// example of how to modify HTML contents
include('../simple_html_dom.php');
// get DOM from URL or file
$html = file_get_html('http://www.google.com/');
// remove all image
foreach($html->find('img') as $e)
$e->outertext = '';
// replace all input
foreach($html->find('input') as $e)
$e->outertext = '[INPUT]';
// dump contents
echo $html;
?>

@ -0,0 +1,44 @@
<?php
include_once('../../simple_html_dom.php');
function scraping_digg() {
// create HTML DOM
$html = file_get_html('http://digg.com/');
// get news block
foreach($html->find('div.news-summary') as $article) {
// get title
$item['title'] = trim($article->find('h3', 0)->plaintext);
// get details
$item['details'] = trim($article->find('p', 0)->plaintext);
// get intro
$item['diggs'] = trim($article->find('li a strong', 0)->plaintext);
$ret[] = $item;
}
// clean up memory
$html->clear();
unset($html);
return $ret;
}
// -----------------------------------------------------------------------------
// test it!
// "http://digg.com" will check user_agent header...
ini_set('user_agent', 'My-Application/2.5');
$ret = scraping_digg();
foreach($ret as $v) {
echo $v['title'].'<br>';
echo '<ul>';
echo '<li>'.$v['details'].'</li>';
echo '<li>Diggs: '.$v['diggs'].'</li>';
echo '</ul>';
}
?>

@ -0,0 +1,51 @@
<?php
include_once('../../simple_html_dom.php');
function scraping_IMDB($url) {
// create HTML DOM
$html = file_get_html($url);
// get title
$ret['Title'] = $html->find('title', 0)->innertext;
// get rating
$ret['Rating'] = $html->find('div[class="general rating"] b', 0)->innertext;
// get overview
foreach($html->find('div[class="info"]') as $div) {
// skip user comments
if($div->find('h5', 0)->innertext=='User Comments:')
return $ret;
$key = '';
$val = '';
foreach($div->find('*') as $node) {
if ($node->tag=='h5')
$key = $node->plaintext;
if ($node->tag=='a' && $node->plaintext!='more')
$val .= trim(str_replace("\n", '', $node->plaintext));
if ($node->tag=='text')
$val .= trim(str_replace("\n", '', $node->plaintext));
}
$ret[$key] = $val;
}
// clean up memory
$html->clear();
unset($html);
return $ret;
}
// -----------------------------------------------------------------------------
// test it!
$ret = scraping_IMDB('http://imdb.com/title/tt0335266/');
foreach($ret as $k=>$v)
echo '<strong>'.$k.' </strong>'.$v.'<br>';
?>

@ -0,0 +1,35 @@
<?php
include_once('../../simple_html_dom.php');
function scraping_slashdot() {
// create HTML DOM
$html = file_get_html('http://slashdot.org/');
// get article block
foreach($html->find('div[id^=firehose-]') as $article) {
// get title
$item['title'] = trim($article->find('a.datitle', 0)->plaintext);
// get body
$item['body'] = trim($article->find('div.body', 0)->plaintext);
$ret[] = $item;
}
// clean up memory
$html->clear();
unset($html);
return $ret;
}
// -----------------------------------------------------------------------------
// test it!
$ret = scraping_slashdot();
foreach($ret as $v) {
echo $v['title'].'<br>';
echo '<ul>';
echo '<li>'.$v['body'].'</li>';
echo '</ul>';
}
?>

@ -0,0 +1,35 @@
<?php
include_once('../simple_html_dom.php');
// -----------------------------------------------------------------------------
// remove HTML comments
function html_no_comment($url) {
// create HTML DOM
$html = file_get_html($url);
// remove all comment elements
foreach($html->find('comment') as $e)
$e->outertext = '';
$ret = $html->save();
// clean up memory
$html->clear();
unset($html);
return $ret;
}
// -----------------------------------------------------------------------------
// search elements that contains an specific text
function find_contains($html, $selector, $keyword, $index=-1) {
$ret = array();
foreach ($html->find($selector) as $e) {
if (strpos($e->innertext, $keyword)!==false)
$ret[] = $e;
}
if ($index<0) return $ret;
return (isset($ret[$index])) ? $ret[$index] : null;
}
?>

@ -0,0 +1,113 @@
/*$Rev: 46 $*/
body {
margin: 0;
padding: 0;
font-family: verdana,arial,helvetica,sans-serif;
font-size: 11px;
color: #4F5155;
}
#content {
margin: 0 20px 0 20px;
line-height: 16px;
padding: 0;
}
h1 {
font-size: 18px;
margin: 0;
padding: 0 0 2px 0;
background-color: #D0D0D0;
text-align: center;
}
h2 {
background-color: #727EA3;
border-right: 1px solid #D0D0D0;
border-bottom: 1px solid #D0D0D0;
color: #FFFFFF;
font-size: 14px;
font-weight: bold;
margin: 14px 0 4px 0;
padding: 1px 10px 1px 10px;
}
ul {
margin-top: 0;
margin-bottom: 0;
line-height:1.5em;
list-style-image:url(bullet.gif);
list-style-type:square;
}
.top {
font-size: 11px;
float: right;
}
.code {
font-size: 11px;
font-family: Monaco, Verdana, Sans-serif;
line-height: 14px;
background-color: #f6f6f6;
border-bottom: 1px solid #D0D0D0;
border-top: 1px solid #A0A0A0;
border-left: 1px solid #A0A0A0;
border-right: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 2px 0 2px 0;
padding: 2px 10px 2px 10px;
}
.code A:link {color: #002166; text-decoration: none; font-weight: bold;}
.code A:visited {color: #002166; text-decoration: none; font-weight: bold;}
.code A:active {color: #002166; text-decoration: none; font-weight: bold;}
.code A:hover {color: #0000ff; text-decoration: underline; font-weight: bold;}
.code .keyword {
color: #007700;
}
.code .comment {
font-size: 10px;
color: #888;
}
.code .var {
color: #770000;
}
th {
font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
color: #000000;
background-color: #CFD4E6;
margin: 2px 2px 2px 2px;
padding: 2px 2px 2px 2px;
font-size: 13px;
font-weight: normal;
font-style: normal;
}
td {
background-color: #dddddd;
}
.description {
font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
font-size: 11px;
color: #333;
text-ident: 30px;
font-style: normal;
}
.returns {
font-family: Monaco, Verdana, Sans-serif;
font-size: 10px;
color: #888;
float: left;
text-align: right;
margin: 0 4px 0 0;
width: 48px;
}

@ -0,0 +1,116 @@
/* Caution! Ensure accessibility in print and other media types... */
@media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */
.ui-tabs-hide {
display: none;
}
}
/* Hide useless elements in print layouts... */
@media print {
.ui-tabs-nav {
display: none;
}
}
/* Skin */
.ui-tabs-nav, .ui-tabs-panel {
font-family: "Trebuchet MS", Trebuchet, Verdana, Helvetica, Arial, sans-serif;
font-size: 12px;
}
.ui-tabs-nav {
list-style: none;
margin: 0;
padding: 0 0 0 4px;
}
.ui-tabs-nav:after { /* clearing without presentational markup, IE gets extra treatment */
display: block;
clear: both;
content: " ";
}
.ui-tabs-nav li {
float: left;
margin: 0 0 0 1px;
min-width: 84px; /* be nice to Opera */
}
.ui-tabs-nav a, .ui-tabs-nav a span {
display: block;
padding: 0 10px;
background: url(../img/tab.png) no-repeat;
}
.ui-tabs-nav a {
margin: 1px 0 0; /* position: relative makes opacity fail for disabled tab in IE */
padding-left: 0;
color: #27537a;
font-weight: bold;
line-height: 1.2;
text-align: center;
text-decoration: none;
white-space: nowrap; /* required in IE 6 */
outline: 0; /* prevent dotted border in Firefox */
}
.ui-tabs-nav .ui-tabs-selected a {
position: relative;
top: 1px;
z-index: 2;
margin-top: 0;
color: #000;
}
.ui-tabs-nav a span {
width: 64px; /* IE 6 treats width as min-width */
min-width: 64px;
height: 18px; /* IE 6 treats height as min-height */
min-height: 18px;
padding-top: 6px;
padding-right: 0;
}
*>.ui-tabs-nav a span { /* hide from IE 6 */
width: auto;
height: auto;
}
.ui-tabs-nav .ui-tabs-selected a span {
padding-bottom: 1px;
}
.ui-tabs-nav .ui-tabs-selected a, .ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active {
background-position: 100% -150px;
}
.ui-tabs-nav a, .ui-tabs-nav .ui-tabs-disabled a:hover, .ui-tabs-nav .ui-tabs-disabled a:focus, .ui-tabs-nav .ui-tabs-disabled a:active {
background-position: 100% -100px;
}
.ui-tabs-nav .ui-tabs-selected a span, .ui-tabs-nav a:hover span, .ui-tabs-nav a:focus span, .ui-tabs-nav a:active span {
background-position: 0 -50px;
}
.ui-tabs-nav a span, .ui-tabs-nav .ui-tabs-disabled a:hover span, .ui-tabs-nav .ui-tabs-disabled a:focus span, .ui-tabs-nav .ui-tabs-disabled a:active span {
background-position: 0 0;
}
.ui-tabs-nav .ui-tabs-selected a:link, .ui-tabs-nav .ui-tabs-selected a:visited, .ui-tabs-nav .ui-tabs-disabled a:link, .ui-tabs-nav .ui-tabs-disabled a:visited { /* @ Opera, use pseudo classes otherwise it confuses cursor... */
cursor: text;
}
.ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active,
.ui-tabs-nav .ui-tabs-unselect a:hover, .ui-tabs-nav .ui-tabs-unselect a:focus, .ui-tabs-nav .ui-tabs-unselect a:active { /* @ Opera, we need to be explicit again here now... */
cursor: pointer;
}
.ui-tabs-disabled {
opacity: .4;
filter: alpha(opacity=40);
}
.ui-tabs-panel {
border-top: 1px solid #97a5b0;
padding: 2px 4px 2px 4px;
background: #fff; /* declare background color for container to avoid distorted fonts in IE while fading */
border: 1px solid #D0D0D0;
border-bottom: 1px solid #A0A0A0;
border-right: 1px solid #A0A0A0;
}
.ui-tabs-loading em {
padding: 0 0 0 20px;
background: url(loading.gif) no-repeat 0 50%;
}
/* Additional IE specific bug fixes... */
* html .ui-tabs-nav { /* auto clear, @ IE 6 & IE 7 Quirks Mode */
display: inline-block;
}
*:first-child+html .ui-tabs-nav { /* @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
display: inline-block;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

@ -0,0 +1,448 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP Simple HTML DOM Parser: Manual</title>
<link href="css/default.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/ui.tabs.css" type="text/css" media="print, projection, screen">
<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/ui.tabs.pack.js"></script>
<script language="JavaScript" type="text/JavaScript">
$(document).ready(function(){
$(function() {$('#container_quickstart > ul').tabs();});
$(function() {$('#container_create > ul').tabs();});
$(function() {$('#container_find > ul').tabs();});
$(function() {$('#container_access > ul').tabs();});
$(function() {$('#container_traverse > ul').tabs();});
$(function() {$('#container_dump > ul').tabs();});
$(function() {$('#container_callback > ul').tabs();});
});
</script>
</head>
<body>
<h1><a name="top"></a>PHP Simple HTML DOM Parser Manual</h1>
<div id="content">
<h2>Index</h2>
<ul>
<li><a href="#section_quickstart">Quick Start</a></li>
<li><a href="#section_create">How to create HTML DOM object?</a></li>
<li><a href="#section_find">How to find HTML elements?</a></li>
<li><a href="#section_access">How to access the HTML element's attributes?</a> </li>
<li><a href="#section_traverse">How to traverse the DOM tree?</a></li>
<li><a href="#section_dump">How to dump contents of DOM object?</a></li>
<li><a href="#section_callback">How to customize the parsing behavior?</a></li>
<li><a href="manual_api.htm">API Reference</a></li>
<li><a href="manual_faq.htm">FAQ</a></li>
</ul>
<a name="section_quickstart"></a>
<h2>Quick Start</h2>
<a class="top" href="#top">Top</a>
<div id="container_quickstart">
<ul>
<li><a href="#fragment-11"><span>Get HTML elements</span></a></li>
<li><a href="#fragment-12"><span>Modify HTML elements</span></a></li>
<li><a href="#fragment-13"><span>Extract contents from HTML</span></a></li>
<li><a href="#fragment-14"><span>Scraping Slashdot!</span></a></li>
</ul>
<div id="fragment-11">
<div class="code">
<span class="comment">// Create DOM from URL or file</span><br>
$html = <strong>file_get_html</strong>(<span class="var">'http://www.google.com/'</span>);<br>
<br>
<span class="comment">// Find all images </span><br>
foreach($html-&gt;<strong>find</strong>(<span class="var">'img'</span>) as $element) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $element-&gt;<strong>src</strong> . <span class="var">'&lt;br&gt;'</span>;<br>
<br>
<span class="comment">// Find all links </span><br>
foreach($html-&gt;<strong>find</strong>(<span class="var">'a'</span>) as $element) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $element-&gt;<strong>href</strong> . <span class="var">'&lt;br&gt;'</span>; </div>
</div>
<div id="fragment-12">
<div class="code">
<span class="comment">// Create DOM from string</span><br>
$html = <strong>str_get_html</strong>(<span class="var">'&lt;div id=&quot;hello&quot;&gt;Hello&lt;/div&gt;&lt;div id=&quot;world&quot;&gt;World&lt;/div&gt;'</span>);<span class="comment"><br>
<br>
</span>
$html-&gt;<strong>find</strong>(<span class="var">'div', 1</span>)-&gt;<strong>class</strong> = <span class="var">'bar'</span>;<br>
<br>
$html-&gt;<strong>find</strong>(<span class="var">'div[id=hello]', 0</span>)-&gt;<strong>innertext</strong> = <span class="var">'foo'</span>;<br>
<br>
echo $html; <span class="comment">// Output: &lt;div id=&quot;hello&quot;&gt;<strong>foo</strong>&lt;/div&gt;&lt;div id=&quot;world&quot; <strong>class=&quot;bar&quot;</strong>&gt;World&lt;/div&gt;</span> </div>
</div>
<div id="fragment-13">
<div class="code"><br>
<span class="comment">// Dump contents (without tags) from HTML</span><br>
echo <strong>file_get_html</strong>(<span class="var">'http://www.google.com/'</span>)-&gt;<strong>plaintext</strong>;
<br>
<br>
</div>
</div>
<div id="fragment-14">
<div class="code">
<span class="comment">// Create DOM from URL</span><br>
$html = <strong>file_get_html</strong>(<span class="var">'http://slashdot.org/'</span>);<br>
<br>
<span class="comment">// Find all article blocks</span><br>
foreach($html-&gt;<strong>find</strong>(<span class="var">'div.article'</span>) as $article) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;$item[<span class="var">'title'</span>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= $article-&gt;<strong>find</strong>(<span class="var">'div.title'</span>, <span class="var">0</span>)-&gt;<strong>plaintext</strong>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;$item[<span class="var">'intro'</span>]&nbsp;&nbsp;&nbsp;&nbsp;= $article-&gt;<strong>find</strong>(<span class="var">'div.intro'</span>, <span class="var">0</span>)-&gt;<strong>plaintext</strong>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;$item[<span class="var">'details'</span>]&nbsp;= $article-&gt;<strong>find</strong>(<span class="var">'div.details'</span>, <span class="var">0</span>)-&gt;<strong>plaintext</strong>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;$articles[] = $item;<br>
}<br>
<br>
print_r($articles);
</div>
</div>
</div>
<a name="section_create"></a>
<h2>How to create HTML DOM object?</h2>
<a class="top" href="#top">Top</a>
<div id="container_create">
<ul>
<li><a href="#frag_create_quick"><span>Quick way</span></a></li>
<li><a href="#frag_create_oo"><span>Object-oriented way</span></a></li>
</ul>
<div id="frag_create_quick">
<div class="code"><span class="comment">// Create a DOM object from a string</span><br>
$html = <strong>str_get_html</strong>(<span class="var">'&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;'</span>);<br>
<br>
<span class="comment">// Create a DOM object from a URL</span><br>
$html = <strong>file_get_html</strong>(<span class="var">'http://www.google.com/'</span>);<br>
<br>
<span class="comment">// Create a DOM object from a HTML file</span><br>
$html = <strong>file_get_html</strong>(<span class="var">'test.htm'</span>);<span class="comment"><br>
</span></div>
</div>
<div id="frag_create_oo">
<div class="code"><span class="comment">// Create a DOM object</span><br>
$html = new <strong>simple_html_dom</strong>();<br>
<br>
<span class="comment">// Load HTML from a string</span><br>
$html-&gt;<strong>load</strong>(<span class="var">'&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;'</span>);<br>
<br>
<span class="comment">// Load HTML from a URL </span> <br>
$html-&gt;<strong>load_file</strong>(<span class="var">'http://www.google.com/'</span>);<br>
<br>
<span class="comment">// Load HTML from a HTML file</span> <br>
$html-&gt;<strong>load_file</strong>(<span class="var">'test.htm'</span>);</div>
</div>
</div>
<a name="section_find"></a>
<h2>How to find HTML elements?</h2>
<a class="top" href="#top">Top</a>
<div id="container_find">
<ul>
<li><a href="#frag_find_basic"><span>Basics</span></a></li>
<li><a href="#frag_find_advanced"><span>Advanced</span></a></li>
<li><a href="#frag_find_chain"><span>Descendant selectors</span></a></li>
<li><a href="#frag_find_nested"><span>Nested selectors</span></a></li>
<li><a href="#frag_find_attr"><span>Attribute Filters</span></a></li>
<li><a href="#frag_find_textcomment"><span>Text &amp; Comments</span></a></li>
</ul>
<div id="frag_find_basic">
<div class="code"> <span class="comment">// Find all <strong>anchors</strong>, returns a <strong>array</strong> of element objects</span><br>
$ret = $html-&gt;find(<span class="var">'<strong>a</strong>'</span>);<br>
<br>
<span class="comment">// Find <strong>(N)th</strong> <strong>anchor</strong>, returns element object or <strong>null</strong> if not found</span> <span class="comment">(zero based)</span><br>
$ret = $html-&gt;find(<span class="var">'<strong>a</strong>', <strong>0</strong></span>);<br>
<br>
<span class="comment">// Find <strong>lastest</strong> <strong>anchor</strong>, returns element object or <strong>null</strong> if not found</span> <span class="comment">(zero based)</span><br>
$ret = $html-&gt;find(<span class="var">'<strong>a</strong>', <strong>-1</strong></span>); <br>
<br>
<span class="comment">// Find all <strong>&lt;div&gt;</strong> with the <strong>id</strong> attribute</span><br>
$ret = $html-&gt;find(<span class="var">'<strong>div[id]</strong>'</span>);<br>
<br>
<span class="comment">// Find all <strong>&lt;div&gt;</strong> which attribute <strong>id=foo</strong></span><br>
$ret = $html-&gt;find(<span class="var">'<strong>div[id=foo]</strong>'</span>); <br>
</div>
</div>
<div id="frag_find_advanced">
<div class="code"><span class="comment">// Find all element which <strong>id</strong>=foo</span><br>
$ret = $html-&gt;find(<span class="var">'<strong>#foo</strong>'</span>);<br>
<br>
<span class=comment>// Find all element which <strong>class</strong>=foo</span><br>
$ret = $html-&gt;find(<span class=var>'<strong>.foo</strong>'</span>);<br>
<br>
<span class="comment">// Find all element has attribute<strong> id</strong></span><br>
$ret = $html-&gt;find(<span class="var">'<strong>*[id]</strong>'</span>); <br>
<br>
<span class="comment">// Find all <strong>anchors</strong> and <strong>images</strong> </span><br>
$ret = $html-&gt;find(<span class="var">'<strong>a, img</strong>'</span>); <br>
<br>
<span class="comment">// Find all <strong>anchors</strong> and <strong>images</strong> with the "title" attribute</span><br>
$ret = $html-&gt;find(<span class="var">'<strong>a[title], img[title]</strong>'</span>);<br>
</div>
</div>
<div id="frag_find_attr">
<div class="code">
Supports these operators in attribute selectors:<br><br>
<table cellpadding="1" cellspacing="1">
<tr>
<th width="25%">Filter</th>
<th width="75%">Description</th>
</tr>
<tr>
<td>[attribute]</td>
<td>Matches elements that <strong>have</strong> the specified attribute.</td>
</tr>
<tr>
<td>[!attribute]</td>
<td>Matches elements that <strong>don't have</strong> the specified attribute.</td>
</tr>
<tr>
<td>[attribute=value]</td>
<td>Matches elements that have the specified attribute with a <strong>certain value</strong>.</td>
</tr>
<tr>
<td>[attribute!=value]</td>
<td>Matches elements that <strong>don't have</strong> the specified attribute with a certain value.</td>
</tr>
<tr>
<td>[attribute^=value]</td>
<td>Matches elements that have the specified attribute and it <strong>starts</strong> with a certain value.</td>
</tr>
<tr>
<td>[attribute$=value]</td>
<td>Matches elements that have the specified attribute and it <strong>ends</strong> with a certain value.</td>
</tr>
<tr>
<td>[attribute*=value]</td>
<td>Matches elements that have the specified attribute and it <strong>contains</strong> a certain value.</td>
</tr>
</table>
</div>
</div>
<div id="frag_find_chain">
<div class="code"><span class="comment">// Find all &lt;li&gt; in &lt;ul&gt; </span><br>
$es = $html-&gt;find(<span class="var">'<strong>ul li</strong>'</span>);<br>
<br>
<span class="comment">// Find Nested &lt;div&gt; </span><span class="comment">tags</span><br>
$es = $html-&gt;find(<span class="var">'<strong>div div div</strong>'</span>); <br>
<br>
<span class="comment">// Find all &lt;td&gt; in &lt;table&gt; which class=hello </span><br>
$es = $html-&gt;find(<span class="var">'<strong>table.hello td</strong>'</span>);<br>
<br>
<span class="comment">// Find all td tags with attribite align=center in table tags </span><br>
$es = $html-&gt;find(<span class="var">''<strong>table</strong><strong> td[align=center]</strong>'</span>);<br>
</div>
</div>
<div id="frag_find_textcomment">
<div class="code"><span class="comment"> // Find all text blocks </span><br>
$es = $html-&gt;find(<span class="var">'<strong>text</strong>'</span>);<br>
<br>
<span class="comment">// Find all comment (&lt;!--...--&gt;) blocks </span><br>
$es = $html-&gt;find(<span class="var">'<strong>comment</strong>'</span>);<br>
</div>
</div>
<div id="frag_find_nested">
<div class="code"> <span class="comment">// Find all &lt;li&gt; in &lt;ul&gt; </span><br>
foreach($html-&gt;find(<span class="var">'<strong>ul</strong>'</span>) as $ul) <br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach($ul-&gt;find(<span class="var">'<strong>li</strong>'</span>) as $li) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="comment">// do something...</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
}<br>
<br>
<span class="comment">// Find first &lt;li&gt; in first &lt;ul&gt;</span> <br>
$e = $html-&gt;find(<span class="var">'<strong>ul</strong>', <strong>0</strong></span>)-&gt;find(<span class="var">'<strong>li</strong>', <strong>0</strong></span>);<br>
</div>
</div>
</div>
<a name="section_access"></a>
<h2>How to access the HTML element's attributes?</h2>
<a class="top" href="#top">Top</a>
<div id="container_access">
<ul>
<li><a href="#frag_access_attr"><span>Get, Set and Remove attributes</span></a></li>
<li><a href="#frag_access_special"><span>Magic attributes</span></a></li>
<li><a href="#frag_access_tips"><span>Tips</span></a></li>
</ul>
<div id="frag_access_attr">
<div class="code">
<span class="comment">// <strong>Get</strong> a attribute ( If the attribute is <strong>non-value</strong> attribute (eg. checked, selected...), it will returns <strong>true</strong> or <strong>false</strong>)</span><br>
$value = $e-&gt;<strong>href</strong>;<br>
<br>
<span class="comment">// <strong>Set</strong> a attribute(If the attribute is <strong>non-value</strong> attribute (eg. checked, selected...), set it's value as <strong>true</strong> or <strong>false</strong>)</span><br>
$e-&gt;<strong>href</strong> = <span class="var">'my link'</span>;<br>
<br>
<span class="comment">// <strong>Remove</strong> a attribute, set it's value as null! </span><br>
$e-&gt;<strong>href</strong> = <strong><span class="var">null</span></strong>;<br>
<br>
<span class="comment">// <strong>Determine</strong> whether a attribute exist?</span> <br>
if(isset($e-&gt;<strong>href</strong>)) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo <span class="var">'href exist!'</span>;<br>
</div>
</div>
<div id="frag_access_special">
<div class="code"> <span class="comment">// Example</span><br>
<span class="hl-var">$</span><span class="hl-code">html = </span>str_get_html<span class="hl-brackets">(</span><span class="var">&quot;&lt;div&gt;foo &lt;b&gt;bar&lt;/b&gt;&lt;/div&gt;&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;</span> <br>
$e = $html-&gt;find(<span class="var">&quot;div&quot;</span>, <span class="var">0</span>);<br>
<br>
echo $e-&gt;<strong>tag</strong>; <span class="comment">// Returns: &quot; <strong>div</strong>&quot;</span><br>
echo $e-&gt;<strong>outertext</strong>; <span class="comment">// Returns: &quot; <strong>&lt;div&gt;foo &lt;b&gt;bar&lt;/b&gt;&lt;/div&gt;</strong>&quot;</span><br>
echo $e-&gt;<strong>innertext</strong>; <span class="comment">// Returns: &quot; <strong>foo &lt;b&gt;bar&lt;/b&gt;</strong>&quot;</span><br>
echo $e-&gt;<strong>plaintext</strong>; <span class="comment">// Returns: &quot; <strong>foo </strong><strong>bar</strong>&quot;<br>
<br>
</span>
<table cellspacing="1" cellpadding="1">
<tr bgcolor="#CCCCCC">
<th width="25%">Attribute Name</th>
<th width="75%">Usage</th>
</tr>
<tr>
<td>$e-&gt;<strong>tag</strong></td>
<td>Read or write the <strong>tag name</strong> of element.</td>
</tr>
<tr>
<td>$e-&gt;<strong>outertext</strong></td>
<td>Read or write the <strong>outer HTML text </strong> of element.</td>
</tr>
<tr>
<td>$e-&gt;<strong>innertext</strong></td>
<td>Read or write the <strong>inner HTML text </strong> of element.</td>
</tr>
<tr>
<td>$e-&gt;<strong>plaintext</strong></td>
<td>Read or write the <strong>plain text </strong> of element.</td>
</tr>
</table>
</div>
</div>
<div id="frag_access_tips">
<div class="code"><span class="comment">// <strong>Extract</strong> contents from HTML </span><br>
echo <strong>$html</strong>-&gt;<strong>plaintext</strong>;<br>
<br>
<span class="comment">
// <strong>Wrap</strong> a element</span><br>
$e-&gt;<strong>outertext</strong> = <span class="var">'&lt;div class=&quot;wrap&quot;&gt;'</span> . $e-&gt;<strong>outertext</strong> . <span class="var">'&lt;div&gt;</span>';<br>
<br>
<span class="comment">// <strong>Remove</strong> a element, set it's outertext as an empty string </span><br>
$e-&gt;<strong>outertext</strong> = <span class="var">''</span>;<br>
<br>
<span class="comment">// <strong>Append</strong> a element</span><br>
$e-&gt;<strong>outertext</strong> = $e-&gt;<strong>outertext</strong> . <span class="var">'&lt;div&gt;foo</span><span class="var">&lt;div&gt;</span>';<br>
<br>
<span class="comment">// <strong>Insert</strong> a element</span><br>
$e-&gt;<strong>outertext</strong> = <span class="var">'&lt;div&gt;foo</span><span class="var">&lt;div&gt;</span>' . $e-&gt;<strong>outertext</strong>;<br>
</div>
</div>
</div>
<a name="section_traverse"></a>
<h2>How to traverse the DOM tree?</h2>
<a class="top" href="#top">Top</a>
<div id="container_traverse">
<ul>
<li><a href="#frag_traverse_background"><span>Background Knowledge</span></a></li>
<li><a href="#frag_traverse_traverse"><span>Traverse the DOM tree</span></a></li>
</ul>
<div id="frag_traverse_background">
<div class="code"> <span class="comment">// If you are not so familiar with HTML DOM, check this <a href="http://php.net/manual/en/book.dom.php" target="_blank"><span class="var">link</span></a> to learn more... </span><br>
<br>
<span class="comment">// Example</span><br>
echo $html-&gt;<strong>find</strong>(<span class="var">&quot;#div1&quot;, 0</span>)-&gt;<strong>children</strong>(<span class="var">1</span>)-&gt;<strong>children</strong>(<span class="var">1</span>)-&gt;<strong>children</strong>(<span class="var">2</span>)-&gt;<span class="var">id</span>;<br>
<span class="comment">// or</span> <br>
echo $html-&gt;<strong>getElementById</strong>(<span class="var">&quot;div1&quot;</span>)-&gt;<strong>childNodes</strong>(<span class="var">1</span>)-&gt;<strong>childNodes</strong>(<span class="var">1</span>)-&gt;<strong>childNodes</strong>(<span class="var">2</span>)-&gt;<strong>getAttribute</strong>(<span class="var">'id'</span>); </div>
</div>
<div id="frag_traverse_traverse">
<div class="code">You can also call methods with <a href="manual_api.htm#camel"><span class="var">Camel naming convertions</span></a>.<br>
<table cellspacing="1" cellpadding="1">
<tr>
<th> Method </th>
<th> Description</th>
</tr>
<tr>
<td>
<div class="returns">mixed</div>$e-&gt;<strong>children</strong> ( <span class="var">[int $index]</span> ) </td>
<td>Returns the Nth <strong>child object</strong> if <strong>index</strong> is set, otherwise return an <strong>array of children</strong>. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>$e-&gt;<strong>parent</strong> () </td>
<td>Returns the <strong>parent</strong> of element. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>$e-&gt;<strong>first_child</strong> () </td>
<td>Returns the <strong>first child</strong> of element, or <strong>null</strong> if not found. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>$e-&gt;<strong>last_child</strong> () </td>
<td>Returns the <strong>last child</strong> of element, or <strong>null</strong> if not found. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>$e-&gt;<strong>next_sibling</strong> () </td>
<td>Returns the <strong>next sibling</strong> of element, or<strong> null</strong> if not found. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>$e-&gt;<strong>prev_sibling</strong> () </td>
<td>Returns the <strong>previous sibling</strong> of element, or <strong>null</strong> if not found. </td>
</tr>
</table>
</div>
</div>
</div>
<a name="section_dump"></a>
<h2>How to dump contents of DOM object?</h2>
<a class="top" href="#top">Top</a>
<div id="container_dump">
<ul>
<li><a href="#frag_dump_quick"><span>Quick way</span></a></li>
<li><a href="#frag_dump_oo"><span>Object-oriented way</span></a></li>
</ul>
<div id="frag_dump_oo">
<div class="code"><span class="comment">// </span><span class="comment">Dumps the internal DOM tree back into string </span><br>
$str = $html-&gt;<strong>save</strong>();<br>
<br>
<span class="comment">// Dumps the internal DOM tree back into a file</span> <br>
$html-&gt;<strong>save</strong>(<span class="var">'result.htm'</span>);</div>
</div>
<div id="frag_dump_quick">
<div class="code"><span class="comment">// </span><span class="comment">Dumps the internal DOM tree back into string </span><br>
$str = $html;<br>
<br>
<span class="comment">// Print it!</span><br>
echo $html; <br>
</div>
</div>
</div>
<a name="section_callback"></a>
<h2>How to customize the parsing behavior?</h2>
<a class="top" href="#top">Top</a>
<div id="container_callback">
<ul>
<li><a href="#frag_callback"><span>Callback function</span></a></li>
</ul>
<div id="frag_callback">
<div class="code"><span class="comment">// Write a function with parameter &quot;<strong>$element</strong>&quot;</span><br>
function my_callback(<span class="var">$element</span>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">// Hide all &lt;b&gt; tags </span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($element-&gt;tag==<span class="var">'b'</span>)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$element-&gt;outertext = '';<br>
} <br>
<br>
<span class="comment">// Register the callback function with it's <strong>function name</strong></span><br>
$html-&gt;<strong>set_callback</strong>(<span class="var">'my_callback'</span>);<br>
<br>
<span class="comment">// Callback function will be invoked while dumping</span><br>
echo $html;
</div>
</div>
</div>
<div><br>
Author: S.C. Chen (me578022@gmail.com)<br>
Original idea is from Jose Solorzano's <a href="http://php-html.sourceforge.net/">HTML Parser for PHP 4</a>. <br>
Contributions by: Contributions by: Yousuke Kumakura, Vadim Voituk, Antcs<br>
</div>
</div>
</body>
</html>
<!--$Rev: 165 $-->

@ -0,0 +1,320 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP Simple HTML DOM Parser: API Reference</title>
<link href="css/default.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1><a name="top"></a>PHP Simple HTML DOM Parser Manual</h1>
<div id="content">
<h2>Index</h2>
<ul>
<li><a href="manual.htm">Back</a></li>
<li><a href="#api">API Reference</a></li>
<li><a href="#camel">Camel naming conventions</a></li>
</ul>
<a name="api"></a>
<h2>API Reference</h2>
<a class="top" href="#top">Top</a>
<div class="code"> <strong>Helper</strong> functions
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<th width="320">Name</th>
<th>Description</th>
</tr>
<tr>
<td><span class="returns">object</span> str_get_html ( <span class="var">string $content</span> )</td>
<td class="description">Creates a DOM object from a string.</td>
</tr>
<tr>
<td><span class="returns">object</span> file_get_html ( <span class="var">string $filename</span> )</td>
<td class="description">Creates a DOM object from a file or a URL.</td>
</tr>
</table>
<br>
<strong>DOM</strong> methods &amp; properties <br>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<th width="320"> Name</th>
<th> Description</th>
</tr>
<tr>
<td>
<div class="returns">void</div>
__construct ( <span class="var">[string $filename]</span> )</td>
<td class="description">Constructor, set the filename parameter will automatically load the contents, either text or file/url.</td>
</tr>
<tr>
<td>
<div class="returns">string</div>
plaintext</td>
<td class="description">Returns the contents extracted from HTML.</td>
</tr>
<tr>
<td>
<div class="returns">void</div>
clear ()</td>
<td class="description">Clean up memory.</td>
</tr>
<tr>
<td>
<div class="returns">void</div>
load ( <span class="var">string $content </span>)</td>
<td class="description"> Load contents from a <strong>string</strong>. </td>
</tr>
<tr>
<td>
<div class="returns">string</div>
save ( <span class="var">[string $filename]</span> )</td>
<td class="description">Dumps the internal DOM tree back into a <strong>string</strong>. If the $filename is set, result string will save to file. </td>
</tr>
<tr>
<td>
<div class="returns">void</div>
load_file (<span class="var"> string $filename</span> )</td>
<td class="description"> Load contents from a from a file or a URL.</td>
</tr>
<tr>
<td>
<div class="returns">void</div>
set_callback ( <span class="var">string $function_name </span>)</td>
<td class="description">Set a callback function. </td>
</tr>
<tr>
<td>
<div class="returns">mixed</div>
find (<span class="var"> string $selector [, int $index] </span>)</td>
<td class="description">Find elements by the CSS selector. Returns the Nth element <strong>object</strong> if <strong>index</strong> is set, otherwise return an <strong>array</strong> of object. </td>
</tr>
</table>
<br>
<strong>Element</strong> methods &amp; properties <br>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<th width="320">Name</th>
<th>Description</th>
</tr>
<tr>
<td>
<div class="returns">string</div>
<span class="var">[attribute]</span></td>
<td class="description">Read or write element's attribure value. </td>
</tr>
<tr>
<td>
<div class="returns">string</div>
tag</td>
<td class="description">Read or write the tag name of element.</td>
</tr>
<tr>
<td>
<div class="returns">string</div>
outertext</td>
<td class="description">Read or write the outer HTML text of element.</td>
</tr>
<tr>
<td>
<div class="returns">string</div>
innertext</td>
<td class="description">Read or write the inner HTML text of element.</td>
</tr>
<tr>
<td>
<div class="returns">string</div>
plaintext</td>
<td class="description">Read or write the plain text of element.</td>
</tr>
<tr>
<td>
<div class="returns">mixed</div>
find (<span class="var"> string $selector [, int $index] </span>)</td>
<td class="description">Find children by the CSS selector. Returns the Nth element <strong>object</strong> if <strong>index</strong> is set, otherwise, return an <strong>array</strong> of object. </td>
</tr>
</table>
<strong><br>
DOM</strong> traversing<br>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<th width="320">Name</th>
<th>Description</th>
</tr>
<tr>
<td>
<div class="returns">mixed</div>
$e-&gt;children ( <span class="var">[int $index]</span> ) </td>
<td class="description">Returns the Nth child <strong>object</strong> if <strong>index</strong> is set, otherwise return an <strong>array</strong> of children. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>
$e-&gt;parent () </td>
<td class="description">Returns the parent of element. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>
$e-&gt;first_child () </td>
<td class="description">Returns the first child of element, or <strong>null</strong> if not found. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>
$e-&gt;last_child () </td>
<td class="description">Returns the last child of element, or <strong>null</strong> if not found. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>
$e-&gt;next_sibling () </td>
<td class="description">Returns the next sibling of element, or<strong> null</strong> if not found. </td>
</tr>
<tr>
<td>
<div class="returns">element</div>
$e-&gt;prev_sibling () </td>
<td class="description">Returns the previous sibling of element, or <strong>null</strong> if not found. </td>
</tr>
</table>
</div>
<a name="camel"></a>
<h2>Camel naming convertions</h2>
<a class="top" href="#top">Top</a>
<div class="code">You can also call methods with W3C STANDARD camel naming convertions.<br>
<br>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<th width="50%">Method</th>
<th>Mapping</th>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">array</div>
$e-&gt;getAllAttributes () </td>
<td>
<div class="returns">array</div>
$e-&gt;<span class="var">attr</span></td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">string</div>
$e-&gt;getAttribute ( <span class="var">$name</span> ) </td>
<td>
<div class="returns">string</div>
$e-&gt;<span class="var">attribute</span></td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">void</div>
$e-&gt;setAttribute ( <span class="var">$name, $value</span> ) </td>
<td>
<div class="returns">void</div>
$value = $e-&gt;<span class="var">attribute</span></td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">bool</div>
$e-&gt;hasAttribute ( <span class="var">$name</span> ) </td>
<td>
<div class="returns">bool</div>
isset($e-&gt;<span class="var">attribute</span>)</td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">void</div>
$e-&gt;removeAttribute ( <span class="var">$name</span> ) </td>
<td>
<div class="returns">void</div>
$e-&gt;<span class="var">attribute</span> = null</td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;getElementById ( <span class="var">$id</span> ) </td>
<td>
<div class="returns">mixed</div>
$e-&gt;find (<span class="var"> &quot;#$id&quot;, 0 </span>)</td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">mixed</div>
$e-&gt;getElementsById ( <span class="var">$id [,$index] </span> ) </td>
<td>
<div class="returns">mixed</div>
$e-&gt;find (<span class="var"> &quot;#$id&quot; [, int $index] </span>)</td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;getElementByTagName (<span class="var">$name</span> ) </td>
<td>
<div class="returns">mixed</div>
$e-&gt;find (<span class="var"> $name, 0 </span>)</td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">mixed</div>
$e-&gt;getElementsByTagName ( <span class="var">$name [, $index]</span> ) </td>
<td>
<div class="returns">mixed</div>
$e-&gt;find (<span class="var"> $name [, int $index] </span>)</td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;parentNode () </td>
<td>
<div class="returns">element</div>
$e-&gt;parent () </td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">mixed</div>
$e-&gt;childNodes ( <span class="var">[$index]</span> ) </td>
<td>
<div class="returns">mixed</div>
$e-&gt;children ( <span class="var">[int $index]</span> ) </td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;firstChild () </td>
<td>
<div class="returns">element</div>
$e-&gt;first_child () </td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;lastChild () </td>
<td>
<div class="returns">element</div>
$e-&gt;last_child () </td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;nextSibling () </td>
<td>
<div class="returns">element</div>
$e-&gt;next_sibling () </td>
</tr>
<tr bgcolor="#EEEEEE">
<td>
<div class="returns">element</div>
$e-&gt;previousSibling () </td>
<td>
<div class="returns">element</div>
$e-&gt;prev_sibling () </td>
</tr>
</table>
</div>
<div><br>
Author: S.C. Chen (me578022@gmail.com)<br>
Original idea is from Jose Solorzano's <a href="http://php-html.sourceforge.net/">HTML Parser for PHP 4</a>. <br>
Contributions by: Contributions by: Yousuke Kumakura, Vadim Voituk, Antcs<br>
</div>
</div>
</body>
</html>
<!--$Rev: 165 $-->

@ -0,0 +1,91 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP Simple HTML DOM Parser: FAQ</title>
<link href="css/default.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1><a name="top"></a>PHP Simple HTML DOM Parser Manual</h1>
<div id="content">
<h2>FAQ</h2>
<ul>
<li><a href="manual.htm">Back</a></li>
<li><a href="#find">Problem with finding</a></li>
<li><a href="#hosting">Problem with hosting</a></li>
<li><a href="#proxy">Behind a proxy</a></li>
<li><a href="#memory_leak">Memory leak!</a></li>
</ul>
<div>
<a name="find"></a>
<h2>Problem with finding</h2>
<a class="top" href="#top">Top</a>
<div class="code"> <span class="var">Q:</span> Element not found in such case:<br>
$html-&gt;find('div[style=<span class="var">padding: 0px 2px;</span>] span[class=rf]');<br>
<br>
<span class="var">A:</span> If there is blank in selectors, quote it!  <br>
$html-&gt;find('div[style=<strong class="var">&quot;padding: 0px 2px;&quot;</strong>] span[class=rf]');</div>
<a name="hosting"></a>
<h2>Problem with hosting</h2>
<a class="top" href="#top">Top</a>
<div class="code"> <span class="var">Q:</span> On my local server everything works fine, but when I put it on my esternal server it doesn't work. <br>
<br>
<span class="var">A:</span> The "file_get_dom" function is a wrapper of "file_get_contents" function,  you must set "<strong>allow_url_fopen</strong>" as <strong>TRUE</strong> in "php.ini" to allow accessing files via HTTP or FTP. However, some hosting venders disabled PHP's "allow_url_fopen" flag for security issues... PHP provides excellent support for "curl" library to do the same job, Use curl to get the page, then call "str_get_dom" to create DOM object. <br>
<br>
Example: <br>
 <br>
$curl = curl_init(); <br>
curl_setopt(<span class="var">$curl, CURLOPT_URL, 'http://????????'</span>);  <br>
curl_setopt(<span class="var">$curl, CURLOPT_RETURNTRANSFER, 1</span>);  <br>
curl_setopt(<span class="var">$curl, CURLOPT_CONNECTTIMEOUT, 10</span>);  <br>
$str = curl_exec(<span class="var">$curl</span>);  <br>
curl_close($curl);  <br>
 <br>
$html= <strong>str_get_html</strong>($str); <br>
...  </div>
<a name="proxy"></a>
<div>
<h2>Behind a proxy</h2>
<a class="top" href="#top">Top</a>
<div class="code"> <span class="var">Q:</span> My server is behind a Proxy and i can't use file_get_contents b/c it returns a unauthorized error.<br>
<br>
<span class="var">A:</span> Thanks for Shaggy to provide the solution: <br>
 <br>
<span class="comment">// Define a context for HTTP. </span><br>
$context = array<br>
( <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="var">'http'</span> =&gt; array<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="var">'proxy'</span> =&gt; <span class="var">'addresseproxy:portproxy'</span>, <span class="comment">// This needs to be the server and the port of the NTLM Authentication Proxy Server. </span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="var"> 'request_fulluri'</span> =&gt; true, <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ), <br>
); <br>
<br>
$context = <strong>stream_context_create</strong>($context); <br>
 <br>
$html= <strong>file_get_html</strong>(<span class="var">'http://www.php.net'</span>, <span class="var">false</span>, <span class="var">$context</span>); <br>
...<br>
</div>
</div>
<a name="memory_leak"></a>
<h2>Memory leak!</h2>
<a class="top" href="#top">Top</a>
<div class="code"> <span class="var">Q:</span> This script is leaking memory seriously... After it finished running, it's not cleaning up dom object properly from memory.. <br>
<br>
<span class="var">A:</span> Due to php5 circular references memory leak, after creating DOM object, you must call $dom-&gt;clear() to free memory if call file_get_dom() more then once. <br>
<br>
Example: <br>
<br>
$html = file_get_html(...); <br>
<span class="comment">// do something... </span><br>
$html-&gt;clear(); <br>
unset($html);</div>
<br>
Author: S.C. Chen (me578022@gmail.com)<br>
Original idea is from Jose Solorzano's <a href="http://php-html.sourceforge.net/">HTML Parser for PHP 4</a>. <br>
Contributions by: Yousuke Kumakura, Vadim Voituk, Antcs<br>
</div>
</div>
</body>
</html>
<!--$Rev: 165 $-->

@ -0,0 +1,24 @@
<?php
// $Rev: 175 $
error_reporting(E_ALL);
function quick_test($html_dom, $str, $selector, $params=array('inner'=>'', 'plain'=>'', 'outer'=>'')) {
$html_dom->load($str);
$e = $html_dom->find($selector, 0);
if (isset($params['inner']))
assert($e->innertext===$params['inner']);
if (isset($params['plain']))
assert($e->plaintext===$params['plain']);
if (isset($params['outer']))
assert($e->outertext===$params['outer']);
assert($html_dom==$str);
}
foreach (new DirectoryIterator(getcwd()) as $entry) {
if ($entry->isFile() && strpos($entry, '_testcase.')>0) {
echo basename($entry);
require_once($entry);
echo '<br>...pass!<br><br>';
}
}
?>

@ -0,0 +1,74 @@
<?php
// $Rev: 179 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// test problem of last emelemt not found
$str = <<<HTML
<img src="src0"><p>foo</p><img src="src2">
HTML;
function callback_1($e) {
if ($e->tag==='img')
$e->outertext = '';
}
$dom->load($str);
$dom->set_callback('callback_1');
assert($dom=='<p>foo</p>');
// -----------------------------------------------
// innertext test
function callback_2($e) {
if ($e->tag==='p')
$e->innertext = 'bar';
}
$dom->load($str);
$dom->set_callback('callback_2');
assert($dom=='<img src="src0"><p>bar</p><img src="src2">');
// -----------------------------------------------
// attributes test
function callback_3($e) {
if ($e->tag==='img')
$e->src = 'foo';
}
$dom->load($str);
$dom->set_callback('callback_3');
assert($dom=='<img src="foo"><p>foo</p><img src="foo">');
function callback_4($e) {
if ($e->tag==='img')
$e->id = 'foo';
}
$dom->set_callback('callback_4');
assert($dom=='<img src="foo" id="foo"><p>foo</p><img src="foo" id="foo">');
// -----------------------------------------------
// attributes test2
//$dom = str_get_dom($str);
$dom->load($str);
$dom->remove_callback();
$dom->find('img', 0)->id = "foo";
assert($dom=='<img src="src0" id="foo"><p>foo</p><img src="src2">');
function callback_5($e) {
if ($e->src==='src0')
unset($e->id);
}
$dom->set_callback('callback_5');
assert($dom==$str);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,386 @@
<?php
// $Rev: 180 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$html = new simple_html_dom;
// -----------------------------------------------------------------------------
// DOM tree test
$html->load('');
$e = $html->root;
assert($e->first_child()==null);
assert($e->last_child()==null);
assert($e->next_sibling()==null);
assert($e->prev_sibling()==null);
// -----------------------------------------------
$str = '<div id="div1"></div>';
$html->load($str);
$e = $html->root;
assert($e->first_child()->id=='div1');
assert($e->last_child()->id=='div1');
assert($e->next_sibling()==null);
assert($e->prev_sibling()==null);
assert($e->plaintext=='');
assert($e->innertext=='<div id="div1"></div>');
assert($e->outertext==$str);
// -----------------------------------------------
$str = <<<HTML
<div id="div1">
<div id="div10"></div>
<div id="div11"></div>
<div id="div12"></div>
</div>
HTML;
$html->load($str);
assert($html==$str);
$e = $html->find('div#div1', 0);
assert(isset($e->id)==true);
assert(isset($e->_not_exist)==false);
assert($e->first_child()->id=='div10');
assert($e->last_child()->id=='div12');
assert($e->next_sibling()==null);
assert($e->prev_sibling()==null);
// -----------------------------------------------
$str = <<<HTML
<div id="div0">
<div id="div00"></div>
</div>
<div id="div1">
<div id="div10"></div>
<div id="div11"></div>
<div id="div12"></div>
</div>
<div id="div2"></div>
HTML;
$html->load($str);
assert($html==$str);
$e = $html->find('div#div1', 0);
assert($e->first_child()->id=='div10');
assert($e->last_child()->id=='div12');
assert($e->next_sibling()->id=='div2');
assert($e->prev_sibling()->id=='div0');
$e = $html->find('div#div2', 0);
assert($e->first_child()==null);
assert($e->last_child()==null);
$e = $html->find('div#div0 div#div00', 0);
assert($e->first_child()==null);
assert($e->last_child()==null);
assert($e->next_sibling()==null);
assert($e->prev_sibling()==null);
// -----------------------------------------------
$str = <<<HTML
<div id="div0">
<div id="div00"></div>
</div>
<div id="div1">
<div id="div10"></div>
<div id="div11">
<div id="div110"></div>
<div id="div111">
<div id="div1110"></div>
<div id="div1111"></div>
<div id="div1112"></div>
</div>
<div id="div112"></div>
</div>
<div id="div12"></div>
</div>
<div id="div2"></div>
HTML;
$html->load($str);
assert($html==$str);
assert($html->find("#div1", 0)->id=='div1');
assert($html->find("#div1", 0)->children(0)->id=='div10');
assert($html->find("#div1", 0)->children(1)->children(1)->id=='div111');
assert($html->find("#div1", 0)->children(1)->children(1)->children(2)->id=='div1112');
// -----------------------------------------------------------------------------
// no value attr test
$str = <<<HTML
<form name="form1" method="post" action="">
<input type="checkbox" name="checkbox0" checked value="checkbox0">aaa<br>
<input type="checkbox" name="checkbox1" value="checkbox1">bbb<br>
<input type="checkbox" name="checkbox2" value="checkbox2" checked>ccc<br>
</form>
HTML;
$html->load($str);
assert($html==$str);
$counter = 0;
foreach($html->find('input[type=checkbox]') as $checkbox) {
if (isset($checkbox->checked)) {
assert($checkbox->value=="checkbox$counter");
$counter += 2;
}
}
$counter = 0;
foreach($html->find('input[type=checkbox]') as $checkbox) {
if ($checkbox->checked) {
assert($checkbox->value=="checkbox$counter");
$counter += 2;
}
}
$es = $html->find('input[type=checkbox]');
$es[1]->checked = true;
assert($es[1]->outertext=='<input type="checkbox" name="checkbox1" value="checkbox1" checked>');
$es[0]->checked = false;
assert($es[0]=='<input type="checkbox" name="checkbox0" value="checkbox0">');
$es[0]->checked = true;
assert($es[0]->outertext=='<input type="checkbox" name="checkbox0" checked value="checkbox0">');
// -----------------------------------------------------------------------------
// remove attr test
$str = <<<HTML
<input type="checkbox" name="checkbox0">
<input type = "checkbox" name = 'checkbox1' value = "checkbox1">
HTML;
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox0]', 0);
$e->name = null;
assert($e=='<input type="checkbox">');
$e->type = null;
assert($e=='<input>');
// -----------------------------------------------
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox0]', 0);
$e->name = null;
assert($e=='<input type="checkbox">');
$e->type = null;
assert($e=='<input>');
// -----------------------------------------------
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox1]', 0);
$e->value = null;
assert($e=="<input type = \"checkbox\" name = 'checkbox1'>");
$e->type = null;
assert($e=="<input name = 'checkbox1'>");
$e->name = null;
assert($e=='<input>');
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox1]', 0);
$e->type = null;
assert($e=="<input name = 'checkbox1' value = \"checkbox1\">");
$e->name = null;
assert($e=='<input value = "checkbox1">');
$e->value = null;
assert($e=='<input>');
// -----------------------------------------------------------------------------
// remove no value attr test
$str = <<<HTML
<input type="checkbox" checked name='checkbox0'>
<input type="checkbox" name='checkbox1' checked>
HTML;
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox1]', 0);
$e->type = NULL;
assert($e=="<input name='checkbox1' checked>");
$e->name = null;
assert($e=="<input checked>");
$e->checked = NULL;
assert($e=="<input>");
// -----------------------------------------------
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox0]', 0);
$e->type = NULL;
assert($e=="<input checked name='checkbox0'>");
$e->name = NULL;
assert($e=='<input checked>');
$e->checked = NULL;
assert($e=='<input>');
$html->load($str);
assert($html==$str);
$e = $html->find('[name=checkbox0]', 0);
$e->checked = NULL;
assert($e=="<input type=\"checkbox\" name='checkbox0'>");
$e->name = NULL;
assert($e=='<input type="checkbox">');
$e->type = NULL;
assert($e=="<input>");
// -----------------------------------------------------------------------------
// extract text
$str = <<<HTML
<b>okok</b>
HTML;
$html->load($str);
assert($html==$str);
assert($html->plaintext=='okok');
$str = <<<HTML
<div><b>okok</b></div>
HTML;
$html->load($str);
assert($html==$str);
assert($html->plaintext=='okok');
$str = <<<HTML
<div><b>okok</b>
HTML;
$html->load($str);
assert($html==$str);
assert($html->plaintext=='okok');
$str = <<<HTML
<b>okok</b></div>
HTML;
$html->load($str);
assert($html==$str);
assert($html->plaintext=='okok</div>');
// -----------------------------------------------------------------------------
// old fashion camel naming conventions test
$str = <<<HTML
<input type="checkbox" id="checkbox" name="checkbox" value="checkbox" checked>
<input type="checkbox" id="checkbox1" name="checkbox1" value="checkbox1">
<input type="checkbox" id="checkbox2" name="checkbox2" value="checkbox2" checked>
HTML;
$html->load($str);
assert($html==$str);
assert($html->getElementByTagName('input')->hasAttribute('checked')==true);
assert($html->getElementsByTagName('input', 1)->hasAttribute('checked')==false);
assert($html->getElementsByTagName('input', 1)->hasAttribute('not_exist')==false);
assert($html->find('input', 0)->value==$html->getElementByTagName('input')->getAttribute('value'));
assert($html->find('input', 1)->value==$html->getElementsByTagName('input', 1)->getAttribute('value'));
assert($html->find('#checkbox1', 0)->value==$html->getElementById('checkbox1')->getAttribute('value'));
assert($html->find('#checkbox2', 0)->value==$html->getElementsById('checkbox2', 0)->getAttribute('value'));
$e = $html->find('[name=checkbox]', 0);
assert($e->getAttribute('value')=='checkbox');
assert($e->getAttribute('checked')==true);
assert($e->getAttribute('not_exist')=='');
$e->setAttribute('value', 'okok');
assert($e=='<input type="checkbox" id="checkbox" name="checkbox" value="okok" checked>');
$e->setAttribute('checked', false);
assert($e=='<input type="checkbox" id="checkbox" name="checkbox" value="okok">');
$e->setAttribute('checked', true);
assert($e=='<input type="checkbox" id="checkbox" name="checkbox" value="okok" checked>');
$e->removeAttribute('value');
assert($e=='<input type="checkbox" id="checkbox" name="checkbox" checked>');
$e->removeAttribute('checked');
assert($e=='<input type="checkbox" id="checkbox" name="checkbox">');
// -----------------------------------------------
$str = <<<HTML
<div id="div1">
<div id="div10"></div>
<div id="div11"></div>
<div id="div12"></div>
</div>
HTML;
$html->load($str);
assert($html==$str);
$e = $html->find('div#div1', 0);
assert($e->firstChild()->getAttribute('id')=='div10');
assert($e->lastChild()->getAttribute('id')=='div12');
assert($e->nextSibling()==null);
assert($e->previousSibling()==null);
// -----------------------------------------------
$str = <<<HTML
<div id="div0">
<div id="div00"></div>
</div>
<div id="div1">
<div id="div10"></div>
<div id="div11">
<div id="div110"></div>
<div id="div111">
<div id="div1110"></div>
<div id="div1111"></div>
<div id="div1112"></div>
</div>
<div id="div112"></div>
</div>
<div id="div12"></div>
</div>
<div id="div2"></div>
HTML;
$html->load($str);
assert($html==$str);
assert($html->getElementById("div1")->hasAttribute('id')==true);
assert($html->getElementById("div1")->hasAttribute('not_exist')==false);
assert($html->getElementById("div1")->getAttribute('id')=='div1');
assert($html->getElementById("div1")->childNodes(0)->getAttribute('id')=='div10');
assert($html->getElementById("div1")->childNodes(1)->childNodes(1)->getAttribute('id')=='div111');
assert($html->getElementById("div1")->childNodes(1)->childNodes(1)->childNodes(2)->getAttribute('id')=='div1112');
assert($html->getElementsById("div1", 0)->childNodes(1)->id=='div11');
assert($html->getElementsById("div1", 0)->childNodes(1)->childNodes(1)->getAttribute('id')=='div111');
assert($html->getElementsById("div1", 0)->childNodes(1)->childNodes(1)->childNodes(1)->getAttribute('id')=='div1111');
// -----------------------------------------------
$str = <<<HTML
<ul class="menublock">
</li>
<ul>
<li>
<a href="http://www.cyberciti.biz/tips/pollsarchive">Polls Archive</a>
</li>
</ul>
</li>
</ul>
HTML;
$html->load($str);
$ul = $html->find('ul', 0);
assert($ul->first_child()->tag==='ul');
// -----------------------------------------------
$str = <<<HTML
<ul>
<li>Item 1
<ul>
<li>Sub Item 1 </li>
<li>Sub Item 2 </li>
</ul>
</li>
<li>Item 2 </li>
</ul>
HTML;
$html->load($str);
assert($html==$str);
$ul = $html->find('ul', 0);
assert($ul->first_child()->tag==='li');
assert($ul->first_child()->next_sibling()->tag==='li');
// -----------------------------------------------------------------------------
// tear down
$html->clear();
unset($html);
?>

@ -0,0 +1,247 @@
<?php
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// innertext test
$str = <<<HTML
<html>
<head></head>
<body>
<br>
<span>foo</span>
</body>
</html>
HTML;
$dom->load($str);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<html>
<head></head>
<body>
<br>
<span>bar</span>
</body>
</html>
HTML;
$dom->load($str);
$dom->find('span', 0)->innertext = 'bar';
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<html>
<head>ok</head>
<body>
<br>
<span>bar</span>
</body>
</html>
HTML;
$dom->load($str);
$dom->find('head', 0)->innertext = 'ok';
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<b>foo</b>
HTML;
$dom->load($str);
$e = $dom->find('b text', 0);
assert($e->innertext=='foo');
assert($e->outertext=='foo');
$e->innertext = 'bar';
assert($e->innertext=='bar');
assert($e->outertext=='bar');
$e = $dom->find('b', 0);
assert($e->innertext=='bar');
assert($e->outertext=='<b>bar</b>');
// -----------------------------------------------------------------------------
// outertext test
$str = <<<HTML
<table>
<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
HTML;
$dom->load($str);
assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
// -----------------------------------------------
$str = <<<HTML
<table><tr><th>Head1</th><th>Head2</th><th>Head3</th><tr><td>1</td><td>2</td><td>3</td></table>
HTML;
$dom->load($str);
assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th>');
assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td>');
// -----------------------------------------------
$str = <<<HTML
<ul><li><b>li11</b></li><li><b>li12</b></li></ul><ul><li><b>li21</b></li><li><b>li22</b></li></ul>
HTML;
$dom->load($str);
assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li></ul>');
assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li></ul>');
// -----------------------------------------------
$str = <<<HTML
<ul><li><b>li11</b></li><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b></li>
HTML;
$dom->load($str);
assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b></li>');
assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li>');
// -----------------------------------------------
$str = <<<HTML
<ul><li><b>li11</b><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b>
HTML;
$dom->load($str);
assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b>');
assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b>');
// -----------------------------------------------
$str = <<<HTML
<table>
<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
HTML;
$dom->load($str);
assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
// -----------------------------------------------------------------------------
// replacement test
$str = <<<HTML
<div class="class1" id="id2" ><div class="class2">ok</div></div>
HTML;
$dom->load($str);
$es = $dom->find('div');
assert(count($es)==2);
assert($es[0]->innertext=='<div class="class2">ok</div>');
assert($es[0]->outertext=='<div class="class1" id="id2" ><div class="class2">ok</div></div>');
// test isset
$es[0]->class = 'class_test';
assert(isset($es[0]->class)===true);
assert(isset($es[0]->okok)===false);
// test replacement
$es[0]->class = 'class_test';
assert($es[0]->outertext=='<div class="class_test" id="id2" ><div class="class2">ok</div></div>');
// test replacement
$es[0]->tag = 'span';
assert($es[0]->outertext=='<span class="class_test" id="id2" ><div class="class2">ok</div></span>');
// test unset (no more support...)
//$dom = str_get_dom($str);
//$es = $dom->find('div');
//unset($es[0]->class);
//assert($es[0]->outertext=='<div id="id2" ><div class="class2">ok</div></div>');
$dom->load($str);
$es = $dom->find('div');
unset($es[0]->attr['class']);
assert($es[0]->outertext=='<div id="id2" ><div class="class2">ok</div></div>');
// -----------------------------------------------
$str = <<<HTML
<select name=something><options>blah</options><options>blah2</options></select>
HTML;
$dom->load($str);
$e = $dom->find('select[name=something]', 0);
$e->innertext = '';
assert($e->outertext =='<select name=something></select>');
// -----------------------------------------------------------------------------
// nested replacement test
$str = <<<HTML
<div class="class0" id="id0" ><div class="class1">ok</div></div>
HTML;
$dom->load($str);
$es = $dom->find('div');
assert(count($es)==2);
assert($es[0]->innertext=='<div class="class1">ok</div>');
assert($es[0]->outertext=='<div class="class0" id="id0" ><div class="class1">ok</div></div>');
assert($es[1]->innertext=='ok');
assert($es[1]->outertext=='<div class="class1">ok</div>');
// test replacement
$es[1]->innertext = 'okok';
assert($es[1]->outertext=='<div class="class1">okok</div>');
assert($es[0]->outertext=='<div class="class0" id="id0" ><div class="class1">okok</div></div>');
assert($dom=='<div class="class0" id="id0" ><div class="class1">okok</div></div>');
$es[1]->class = 'class_test';
assert($es[1]->outertext=='<div class="class_test">okok</div>');
assert($es[0]->outertext=='<div class="class0" id="id0" ><div class="class_test">okok</div></div>');
assert($dom=='<div class="class0" id="id0" ><div class="class_test">okok</div></div>');
$es[0]->class = 'class_test';
assert($es[0]->outertext=='<div class="class_test" id="id0" ><div class="class_test">okok</div></div>');
assert($dom=='<div class="class_test" id="id0" ><div class="class_test">okok</div></div>');
$es[0]->innertext = 'okokok';
assert($es[0]->outertext=='<div class="class_test" id="id0" >okokok</div>');
assert($dom=='<div class="class_test" id="id0" >okokok</div>');
// -----------------------------------------------------------------------------
// <p> test
$str = <<<HTML
<div class="class0">
<p>ok0<a href="#">link0</a></p>
<div class="class1"><p>ok1<a href="#">link1</a></p></div>
<div class="class2"></div>
<p>ok2<a href="#">link2</a></p>
</div>
HTML;
$dom->load($str);
$es = $dom->find('p');
assert($es[0]->innertext=='ok0<a href="#">link0</a>');
assert($es[1]->innertext=='ok1<a href="#">link1</a>');
assert($es[2]->innertext=='ok2<a href="#">link2</a>');
assert($dom->find('p', 0)->plaintext=='ok0link0');
assert($dom->find('p', 1)->plaintext=='ok1link1');
assert($dom->find('p', 2)->plaintext=='ok2link2');
$count = 0;
foreach($dom->find('p') as $p) {
$a = $p->find('a');
assert($a[0]->innertext=='link'.$count);
++$count;
}
$es = $dom->find('p a');
assert($es[0]->innertext=='link0');
assert($es[1]->innertext=='link1');
assert($es[2]->innertext=='link2');
assert($dom->find('p a', 0)->plaintext=='link0');
assert($dom->find('p a', 1)->plaintext=='link1');
assert($dom->find('p a', 2)->plaintext=='link2');
assert($dom==$str);
// -----------------------------------------------------------------------------
// <embed> test
$str = <<<HTML
<EMBED
SRC="../graphics/sounds/1812over.mid"
HEIGHT=60 WIDTH=144>
HTML;
$dom->load($str);
$e = $dom->find('embed', 0);
assert($e->src=='../graphics/sounds/1812over.mid');
assert($e->height=='60');
assert($e->width=='144');
assert($dom==strtolower($str));
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,658 @@
<?php
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
//self-closing tags test
$str = <<<HTML
<hr>
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->id= 'foo';
assert($e->outertext=='<hr id="foo">');
// -----------------------------------------------
$str = <<<HTML
<hr/>
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->id= 'foo';
assert($e->outertext=='<hr id="foo"/>');
// -----------------------------------------------
$str = <<<HTML
<hr />
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->id= 'foo';
assert($e->outertext=='<hr id="foo" />');
// -----------------------------------------------
$str = <<<HTML
<hr>
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->id= 'foo';
$e->class = 'bar';
assert($e->outertext=='<hr id="foo" class="bar">');
// -----------------------------------------------
$str = <<<HTML
<hr/>
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->id= 'foo';
$e->class = 'bar';
assert($e->outertext=='<hr id="foo" class="bar"/>');
// -----------------------------------------------
$str = <<<HTML
<hr />
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->id= 'foo';
$e->class = 'bar';
assert($e->outertext=='<hr id="foo" class="bar" />');
// -----------------------------------------------
$str = <<<HTML
<hr id="foo" kk=ll>
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->class = 'bar';
assert($e->outertext=='<hr id="foo" kk=ll class="bar">');
// -----------------------------------------------
$str = <<<HTML
<hr id="foo" kk="ll"/>
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->class = 'bar';
assert($e->outertext=='<hr id="foo" kk="ll" class="bar"/>');
// -----------------------------------------------
$str = <<<HTML
<hr id="foo" kk=ll />
HTML;
$dom->load($str);
$e = $dom->find('hr', 0);
$e->class = 'bar';
assert($e->outertext=='<hr id="foo" kk=ll class="bar" />');
// -----------------------------------------------
$str = <<<HTML
<div><nobr></div>
HTML;
$dom->load($str);
$e = $dom->find('nobr', 0);
assert($e->outertext=='<nobr>');
// -----------------------------------------------------------------------------
// optional closing tags test
$str = <<<HTML
<body>
</b><.b></a>
</body>
HTML;
$dom = str_get_html($str);
assert($dom->find('body', 0)->outertext==$str);
// -----------------------------------------------
$str = <<<HTML
<html>
<body>
<a>foo</a>
<a>foo2</a>
HTML;
$dom = str_get_html($str);
assert($dom==$str);
assert($dom->find('html body a', 1)->innertext=='foo2');
// -----------------------------------------------
$str = <<<HTML
HTML;
$dom = str_get_html($str);
assert($dom==$str);
assert($dom->find('html a', 1)===null);
//assert($dom->find('html a', 1)->innertext=='foo2');
// -----------------------------------------------
$str = <<<HTML
<body>
<div>
</body>
HTML;
$dom = str_get_html($str);
assert($dom==$str);
assert($dom->find('body', 0)->outertext==$str);
// -----------------------------------------------
$str = <<<HTML
<body>
<div> </a> </div>
</body>
HTML;
$dom = str_get_html($str);
assert($dom->find('body', 0)->outertext==$str);
// -----------------------------------------------
$str = <<<HTML
<table>
<tr>
<td><b>aa</b>
<tr>
<td><b>bb</b>
</table>
HTML;
$dom = str_get_html($str);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<table>
<tr><td>1<td>2<td>3
</table>
HTML;
$dom = str_get_html($str);
assert(count($dom->find('td'))==3);
assert($dom->find('td', 0)->innertext=='1');
assert($dom->find('td', 0)->outertext=='<td>1');
assert($dom->find('td', 1)->innertext=='2');
assert($dom->find('td', 1)->outertext=='<td>2');
assert($dom->find('td', 2)->innertext=="3\r\n");
assert($dom->find('td', 2)->outertext=="<td>3\r\n");
// -----------------------------------------------
$str = <<<HTML
<table>
<tr>
<td><b>1</b></td>
<td><b>2</b></td>
<td><b>3</b></td>
</table>
HTML;
$dom = str_get_html($str);
assert(count($dom->find('tr td'))==3);
// -----------------------------------------------
$str = <<<HTML
<table>
<tr><td><b>11</b></td><td><b>12</b></td><td><b>13</b></td>
<tr><td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>
</table>
HTML;
$dom = str_get_html($str);
assert(count($dom->find('tr'))==2);
assert(count($dom->find('tr td'))==6);
assert($dom->find('tr', 1)->outertext=="<tr><td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>\r\n");
assert($dom->find('tr', 1)->innertext=="<td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>\r\n");
assert($dom->find('tr', 1)->plaintext=="213243\r\n");
// -----------------------------------------------
$str = <<<HTML
<p>1
<p>2</p>
<p>3
HTML;
$dom = str_get_html($str);
assert(count($dom->find('p'))==3);
assert($dom->find('p', 0)->innertext=="1\r\n");
assert($dom->find('p', 0)->outertext=="<p>1\r\n");
assert($dom->find('p', 1)->innertext=="2");
assert($dom->find('p', 1)->outertext=="<p>2</p>");
assert($dom->find('p', 2)->innertext=="3");
assert($dom->find('p', 2)->outertext=="<p>3");
// -----------------------------------------------
$str = <<<HTML
<nobr>1
<nobr>2</nobr>
<nobr>3
HTML;
$dom = str_get_html($str);
assert(count($dom->find('nobr'))==3);
assert($dom->find('nobr', 0)->innertext=="1\r\n");
assert($dom->find('nobr', 0)->outertext=="<nobr>1\r\n");
assert($dom->find('nobr', 1)->innertext=="2");
assert($dom->find('nobr', 1)->outertext=="<nobr>2</nobr>");
assert($dom->find('nobr', 2)->innertext=="3");
assert($dom->find('nobr', 2)->outertext=="<nobr>3");
// -----------------------------------------------
$str = <<<HTML
<dl><dt>1<dd>2<dt>3<dd>4</dl>
HTML;
$dom = str_get_html($str);
assert(count($dom->find('dt'))==2);
assert(count($dom->find('dd'))==2);
assert($dom->find('dt', 0)->innertext=="1");
assert($dom->find('dt', 0)->outertext=="<dt>1");
assert($dom->find('dt', 1)->innertext=="3");
assert($dom->find('dt', 1)->outertext=="<dt>3");
assert($dom->find('dd', 0)->innertext=="2");
assert($dom->find('dd', 0)->outertext=="<dd>2");
assert($dom->find('dd', 1)->innertext=="4");
assert($dom->find('dd', 1)->outertext=="<dd>4");
// -----------------------------------------------
$str = <<<HTML
<dl id="dl1"><dt>11<dd>12<dt>13<dd>14</dl>
<dl id="dl2"><dt>21<dd>22<dt>23<dd>24</dl>
HTML;
$dom = str_get_html($str);
assert(count($dom->find('#dl1 dt'))==2);
assert(count($dom->find('#dl2 dd'))==2);
assert($dom->find('dl', 0)->innertext=="<dt>11<dd>12<dt>13<dd>14");
assert($dom->find('dl', 1)->innertext=="<dt>21<dd>22<dt>23<dd>24");
// -----------------------------------------------
$str = <<<HTML
<ul id="ul1"><li><b>1</b><li><b>2</b></ul>
<ul id="ul2"><li><b>3</b><li><b>4</b></ul>
HTML;
$dom = str_get_html($str);
assert(count($dom->find('ul[id=ul1] li'))==2);
// -----------------------------------------------------------------------------
// invalid test
$str = <<<HTML
<div>
<div class="class0" id="id0" >
<img class="class0" id="id0" src="src0">
</img>
<img class="class0" id="id0" src="src0">
</div>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('img'))==2);
assert(count($dom->find('img'))==2);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<div>
<div class="class0" id="id0" >
<span></span>
</span>
<span></span>
</div>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('span'))==2);
assert(count($dom->find('div'))==2);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<div>
<div class="class0" id="id0" >
<span></span>
<span>
<span></span>
</div>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('span'))==3);
assert(count($dom->find('div'))==2);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<ul class="menublock">
</li>
<ul>
<li>
<a href="http://www.cyberciti.biz/tips/pollsarchive">Polls Archive</a>
</li>
</ul>
</li>
</ul>
HTML;
$dom->load($str);
assert(count($dom->find('ul'))==2);
assert(count($dom->find('ul ul'))==1);
assert(count($dom->find('li'))==1);
assert(count($dom->find('a'))==1);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<td>
<div>
</span>
</div>
</td>
HTML;
$dom->load($str);
assert(count($dom->find('td'))==1);
assert(count($dom->find('div'))==1);
assert(count($dom->find('td div'))==1);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<td>
<div>
</b>
</div>
</td>
HTML;
$dom->load($str);
assert(count($dom->find('td'))==1);
assert(count($dom->find('div'))==1);
assert(count($dom->find('td div'))==1);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<td>
<div></div>
</div>
</td>
HTML;
$dom->load($str);
assert(count($dom->find('td'))==1);
assert(count($dom->find('div'))==1);
assert(count($dom->find('td div'))==1);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<html>
<body>
<table>
<tr>
foo</span>
<span>bar</span>
</span>important
</tr>
</table>
</bod>
</html>
HTML;
$dom->load($str);
assert(count($dom->find('table span'))===1);
assert($dom->find('table span', 0)->innertext==='bar');
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<td>
<div>
<font>
<b>foo</b>
</div>
</td>
HTML;
$dom->load($str);
assert(count($dom->find('td div font b'))==1);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<span style="okokok">
... then slow into 287
<i>
<b>
<font color="#0000CC">(hanover0...more volume between 202 & 53
<i>
<b>
<font color="#0000CC">(parsippany)</font>
</b>
</i>
...then sluggish in spots out to dover chester road
<i>
<b>
<font color="#0000CC">(randolph)</font>
</b>
</i>..then traffic light delays out to route 46
<i>
<b>
<font color="#0000CC">(roxbury)</font>
</b>
</i>/eb slow into 202
<i>
<b>
<font color="#0000CC">(morris plains)</font>
</b>
</i> & again into 287
<i>
<b>
<font color="#0000CC">(hanover)</font>
</b>
</i>
</span>.
<td class="d N4 c">52</td>
HTML;
$dom->load($str);
assert(count($dom->find('span td'))==0);
assert($dom==$str);
// -----------------------------------------------------------------------------
// invalid '<'
// -----------------------------------------------
$str = <<<HTML
<td><b>test :</b>1 gram but <5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but <5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but <5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but<5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but<5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but<5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but< 5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but< 5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but< 5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but < 5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but < 5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but < 5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5< grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5< grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 < grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 < grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 < grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 <grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<td><b>test :</b>1 gram but 5< grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5< grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but5< grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but5< grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but5< grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 <grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5<grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5<grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5<grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 <grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
assert($dom==$str);
// -----------------------------------------------------------------------------
// invalid '>'
// -----------------------------------------------
$str = <<<HTML
<td><b>test :</b>1 gram but >5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but >5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but >5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but>5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but>5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but>5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but> 5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but> 5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but> 5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but > 5 grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but > 5 grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but > 5 grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5> grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5> grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 > grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 > grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 > grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 >grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<td><b>test :</b>1 gram but 5> grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5> grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but5> grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but5> grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but5> grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 >grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5>grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5>grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5>grams');
assert($dom==$str);
$str = <<<HTML
<td><b>test :</b>1 gram but 5 >grams</td>
HTML;
$dom->load($str);
assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
assert($dom==$str);
// -----------------------------------------------------------------------------
// BAD HTML test
$str = <<<HTML
<strong class="see <a href="http://www.oeb.harvard.edu/faculty/girguis/">http://www.oeb.harvard.edu/faculty/girguis/</a>">.</strong></p>
HTML;
$dom->load($str);
// -----------------------------------------------
$str = <<<HTML
<a href="http://www.oeb.harvard.edu/faculty/girguis\">http://www.oeb.harvard.edu/faculty/girguis/</a>">
HTML;
$dom->load($str);
// -----------------------------------------------
$str = <<<HTML
<strong class="''""";;''""";;\"\''''\"""''''""''>""'''"'" '
HTML;
$dom->load($str);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,68 @@
<?php
// $Rev: 174 $
error_reporting(E_ALL);
include_once('../simple_html_dom.php');
$dir = './html/';
$files = array(
array('name'=>'empty.htm', 'url'=>''),
array('name'=>'smarty_1.htm', 'url'=>'guestbook.tpl'),
array('name'=>'smarty_2.htm', 'url'=>'guestbook_form.tpl'),
array('name'=>'google.htm', 'url'=>'http://www.google.com/'),
array('name'=>'senate.htm', 'url'=>'http://www.senate.gov/legislative/LIS/roll_call_lists/roll_call_vote_cfm.cfm?congress=101&session=2&vote=00317'),
array('name'=>'cyberciti.htm', 'url'=>'http://www.cyberciti.biz/tips/configure-ubuntu-grub-to-load-freebsd.html'),
array('name'=>'myspace.htm', 'url'=>'http://www.myspace.com/'),
array('name'=>'mootools.htm', 'url'=>'http://www.mootools.net/'),
array('name'=>'jquery.htm', 'url'=>'http://jquery.com/'),
array('name'=>'scriptaculo.htm', 'url'=>'http://script.aculo.us/'),
array('name'=>'apache.htm', 'url'=>'http://www.apache.org/'),
array('name'=>'microsoft.htm', 'url'=>'http://www.microsoft.com/'),
array('name'=>'slashdot.htm', 'url'=>'http://www.slashdot.org/'),
array('name'=>'ror.htm', 'url'=>'http://www.rubyonrails.org/'),
array('name'=>'yahoo.htm', 'url'=>'http://www.yahoo.com/'),
array('name'=>'phpbb.htm', 'url'=>'http://www.phpbb.com/'),
array('name'=>'python.htm', 'url'=>'http://www.python.org/'),
array('name'=>'lua.htm', 'url'=>'http://www.lua.org/'),
array('name'=>'php.htm', 'url'=>'http://www.php.net/'),
array('name'=>'ibm.htm', 'url'=>'http://www.ibm.com/'),
array('name'=>'java.htm', 'url'=>'http://java.sun.com/'),
array('name'=>'flickr.htm', 'url'=>'http://www.flickr.com/tour/upload/'),
array('name'=>'amazon.htm', 'url'=>'http://www.amazon.com/'),
array('name'=>'youtube.htm', 'url'=>'http://www.youtube.com/watch?v=kib05Ip6GSo&feature=bz302'),
);
echo 'memory: '.memory_get_usage().'<br>';
$dom = new simple_html_dom;
foreach($files as $f) {
// get file from url
if($f['url']!='') file_put_contents($dir.$f['name'], file_get_contents($f['url']));
else file_put_contents($dir.$f['name'], '');
$start = microtime();
$dom->load(file_get_contents($dir.$f['name']), false);
list($eu, $es) = explode(' ', microtime());
list($bu, $bs) = explode(' ', $start);
echo sprintf('(%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br>';
if (file_get_contents($dir.$f['name'])!=$dom->save()) {
echo "[<font color='red'>failed</font>] ".$f['name']."<br>";
$dom->save($dir.$f['name'].'.error');
}
else
echo "[success] ".$f['name']."<br>";
echo 'memory: '.memory_get_usage().'<br>';
flush();
set_time_limit(0);
}
$dom->clear();
unset($dom);
echo '<br>memory: '.memory_get_usage().'<br>';
?>

@ -0,0 +1,121 @@
<?php
// $Rev: 179 $
error_reporting(E_ALL);
include_once('../simple_html_dom.php');
// -----------------------------------------------------------------------------
function dump_memory($init_size) {
$peak = number_format(memory_get_peak_usage()/1024, 0, '.', ',');
$curr = number_format(memory_get_usage()/1024, 0, '.', ',');
$diff = $curr - $init_size;
echo 'peak: ' . $peak . ' kb, end: ' . $curr . ' kb, add: ' . $diff . " kb<br>";
}
// -----------------------------------------------------------------------------
$filename = './html/google.htm';
//$filename = 'test.htm';
// -----------------------------------------------------------------------------
// test_load_file_memory
function test_load_file_memory($filename, $init_size) {
echo '[load file] init memory: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
echo '--------------------------------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$str = file_get_contents($filename);
dump_memory($init_size);
unset($str);
}
echo 'after loop: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '--------------------------------------------------------------------<br>';
flush();
}
// -----------------------------------------------------------------------------
// test_multi_objects_str_get_html
function test_multi_str_get_html($filename, $init_size) {
global $__g_node_mgr;
$str = file_get_contents($filename);
echo '[str_get_html] init memory: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
echo '--------------------------------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$html = str_get_html($str);
dump_memory($init_size);
flush();
}
echo 'after loop: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '--------------------------------------------------------------------<br>';
flush();
unset($str);
}
// -----------------------------------------------------------------------------
// test_multi_file_get_html
function test_multi_file_get_html($filename, $init_size) {
echo '[file_get_html] init memory: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
echo '--------------------------------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$html = file_get_html($filename);
//$html->clear();
unset($html);
dump_memory($init_size);
flush();
}
echo 'after loop: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '--------------------------------------------------------------------<br>';
flush();
}
/*
// -----------------------------------------------------------------------------
// test_multi_objects_clear_memory
function test_multi_objects_file_get_html_clear_memory($filename) {
echo '<br><br>[one object]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
$html = new simple_html_dom;
for($i=0; $i<3; ++$i) {
$html->load_file($filename);
$html->clear();
dump_memory();
}
unset($dom);
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
echo '<br><br>[multi objects without clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$html = file_get_html($filename);
dump_memory();
}
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
*/
// -----------------------------------------------------------------------------
// begin test
$init_size = number_format(memory_get_usage(), 0, '.', ',');
echo 'init ' . $init_size . " bytes<br>";
flush();
echo '<br>before function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
test_load_file_memory($filename, $init_size);
echo 'after function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br><br>';
flush();
echo '<br>before function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
test_multi_file_get_html($filename, $init_size);
echo 'after function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br><br>';
flush();
echo '<br>before function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
test_multi_file_get_html($filename, $init_size);
echo 'after function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br><br>';
flush();
?>

@ -0,0 +1,60 @@
<?php
// $Rev: 133 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// test problem of last emelemt not found
$str = <<<HTML
<img class="class0" id="id0" src="src0">
<img class="class1" id="id1" src="src1">
<img class="class2" id="id2" src="src2">
HTML;
$dom->load($str);
$es = $dom->find('img');
assert(count($es)==3);
assert($es[0]->src=='src0');
assert($es[1]->src=='src1');
assert($es[2]->src=='src2');
assert($es[0]->innertext=='');
assert($es[1]->innertext=='');
assert($es[2]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
assert($es[1]->outertext=='<img class="class1" id="id1" src="src1">');
assert($es[2]->outertext=='<img class="class2" id="id2" src="src2">');
assert($dom->find('img', 0)->src=='src0');
assert($dom->find('img', 1)->src=='src1');
assert($dom->find('img', 2)->src=='src2');
assert($dom->find('img', 3)===null);
assert($dom->find('img', 99)===null);
assert($dom->save()==$str);
// -----------------------------------------------------------------------------
// test error tag
$str = <<<HTML
<img class="class0" id="id0" src="src0"><p>p1</p>
<img class="class1" id="id1" src="src1"><p>
<img class="class2" id="id2" src="src2"></a></div>
HTML;
$dom = str_get_html($str);
$es = $dom->find('img');
assert(count($es)==3);
assert($es[0]->src=='src0');
assert($es[1]->src=='src1');
assert($es[2]->src=='src2');
$es = $dom->find('p');
assert($es[0]->innertext=='p1');
assert($dom==$str);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,40 @@
<?php
// $Rev: 133 $
error_reporting(E_ALL);
include_once('../simple_html_dom.php');
$all = 0;
$min = 10000;
$max = 0;
$count = 20;
$str = file_get_contents('./html/google.htm');
$html = new simple_html_dom;
for ($i=0; $i<$count; ++$i) {
$start = microtime();
$html->load($str, false);
list($eu, $es) = explode(' ', microtime());
list($bu, $bs) = explode(' ', $start);
$diff = ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
if ($diff>$max)
$max = $diff;
if ($diff<$min)
$min = $diff;
$all += $diff;
echo sprintf('(%.1f)', $diff).'<br>';
}
echo '<br>-------------------------<br>';
echo 'min: ' . $min . '<br>';
echo 'max: ' . $max . '<br>';
echo '<br>avg: ' . $all/$count . '<br>';
?>

@ -0,0 +1,12 @@
<?php
// $Rev: 129 $
error_reporting(E_ALL);
foreach (new DirectoryIterator(getcwd()) as $entry) {
if ($entry->isFile() && strpos($entry, '_testcase.')>0) {
echo basename($entry);
require_once($entry);
echo '<br>...pass!<br><br>';
}
}
?>

@ -0,0 +1,243 @@
<?php
// $Rev: 130 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../../simple_html_dom_reader.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// attribute test
$str = <<<HTML
<div onclick="bar('aa')">foo</div>
HTML;
$dom->load($str);
assert($dom->find('div', 0)==$str);
// -----------------------------------------------
$str = <<<HTML
<div onclick='bar("aa")'>foo</div>
HTML;
$dom->load($str);
assert($dom->find('div', 0)==$str);
// -----------------------------------------------------------------------------
// innertext test
$str = <<<HTML
<html><head></head><body><br><span>foo</span></body></html>
HTML;
$dom->load($str);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<html><head></head><body><br><span>bar</span></body></html>
HTML;
$dom->find('span', 0)->innertext = 'bar';
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<html><head>ok</head><body><br><span>bar</span></body></html>
HTML;
$dom->find('head', 0)->innertext = 'ok';
assert($dom==$str);
// -----------------------------------------------------------------------------
// outertext test
$str = <<<HTML
<table>
<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
HTML;
$dom->load($str);
assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
// -----------------------------------------------
$str = <<<HTML
<table><tr><th>Head1</th><th>Head2</th><th>Head3</th><tr><td>1</td><td>2</td><td>3</td></table>
HTML;
$dom->load($str);
assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
// -----------------------------------------------
$str = <<<HTML
<ul><li><b>li11</b></li><li><b>li12</b></li></ul><ul><li><b>li21</b></li><li><b>li22</b></li></ul>
HTML;
$dom->load($str);
assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li></ul>');
assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li></ul>');
// -----------------------------------------------
$str = <<<HTML
<ul><li><b>li11</b></li><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b></li>
HTML;
//$dom->load($str);
//assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li></ul>');
//assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li></ul>');
// -----------------------------------------------
$str = <<<HTML
<ul><li><b>li11</b><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b>
HTML;
//$dom->load($str);
//assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b><li><b>li12</b></li>');
//assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b>');
// -----------------------------------------------
$str = <<<HTML
<table>
<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
HTML;
$dom->load($str);
assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
// -----------------------------------------------------------------------------
// replacement test
$str = <<<HTML
<div class="class1" id="id2" ><div class="class2">ok</div></div>
HTML;
$dom->load($str);
$es = $dom->find('div');
assert(count($es)==2);
assert($es[0]->innertext=='<div class="class2">ok</div>');
assert($es[0]->outertext=='<div class="class1" id="id2"><div class="class2">ok</div></div>');
// test isset
$es[0]->class = 'class_test';
assert(isset($es[0]->class)===true);
assert(isset($es[0]->okok)===false);
// test replacement
$es[0]->class = 'class_test';
assert($es[0]->outertext=='<div class="class_test" id="id2"><div class="class2">ok</div></div>');
// test replacement
//$es[0]->tag = 'span';
//assert($es[0]->outertext=='<span class="class_test" id="id2"><div class="class2">ok</div></span>');
// test unset (no more support...)
//$dom = str_get_dom($str);
//$es = $dom->find('div');
//unset($es[0]->class);
//assert($es[0]->outertext=='<div id="id2" ><div class="class2">ok</div></div>');
//$dom->load($str);
//$es = $dom->find('div');
//unset($es[0]->attr['class']);
//assert($es[0]->outertext=='<div id="id2"><div class="class2">ok</div></div>');
// -----------------------------------------------
$str = <<<HTML
<select name=something><options>blah</options><options>blah2</options></select>
HTML;
$dom->load($str);
$e = $dom->find('select[name=something]', 0);
$e->innertext = '';
assert($e->outertext =='<select name="something"></select>');
// -----------------------------------------------------------------------------
// nested replacement test
$str = <<<HTML
<div class="class0" id="id0"><div class="class1">ok</div></div>
HTML;
$dom->load($str);
$es = $dom->find('div');
assert(count($es)==2);
assert($es[0]->innertext=='<div class="class1">ok</div>');
assert($es[0]->outertext=='<div class="class0" id="id0"><div class="class1">ok</div></div>');
assert($es[1]->innertext=='ok');
assert($es[1]->outertext=='<div class="class1">ok</div>');
// test replacement
$es[1]->innertext = 'okok';
assert($es[1]->outertext=='<div class="class1">okok</div>');
assert($es[0]->outertext=='<div class="class0" id="id0"><div class="class1">okok</div></div>');
//assert($dom=='<div class="class0" id="id0"><div class="class1">okok</div></div>');
$es[1]->class = 'class_test';
assert($es[1]->outertext=='<div class="class_test">okok</div>');
assert($es[0]->outertext=='<div class="class0" id="id0"><div class="class_test">okok</div></div>');
//assert($dom=='<div class="class0" id="id0"><div class="class_test">okok</div></div>');
$es[0]->class = 'class_test';
assert($es[0]->outertext=='<div class="class_test" id="id0"><div class="class_test">okok</div></div>');
//assert($dom=='<div class="class_test" id="id0"><div class="class_test">okok</div></div>');
$es[0]->innertext = 'okokok';
assert($es[0]->outertext=='<div class="class_test" id="id0">okokok</div>');
//assert($dom=='<div class="class_test" id="id0">okokok</div>');
// -----------------------------------------------------------------------------
// <p> test
$str = <<<HTML
<div class="class0"><p>ok0<a href="#">link0</a></p><div class="class1"><p>ok1<a href="#">link1</a></p></div><div class="class2"></div><p>ok2<a href="#">link2</a></p></div>
HTML;
$dom->load($str);
$es = $dom->find('p');
assert($es[0]->innertext=='ok0<a href="#">link0</a>');
assert($es[1]->innertext=='ok1<a href="#">link1</a>');
assert($es[2]->innertext=='ok2<a href="#">link2</a>');
assert($dom->find('p', 0)->plaintext=='ok0link0');
assert($dom->find('p', 1)->plaintext=='ok1link1');
assert($dom->find('p', 2)->plaintext=='ok2link2');
$count = 0;
foreach($dom->find('p') as $p) {
$a = $p->find('a');
assert($a[0]->innertext=='link'.$count);
++$count;
}
$es = $dom->find('p a');
assert($es[0]->innertext=='link0');
assert($es[1]->innertext=='link1');
assert($es[2]->innertext=='link2');
assert($dom->find('p a', 0)->plaintext=='link0');
assert($dom->find('p a', 1)->plaintext=='link1');
assert($dom->find('p a', 2)->plaintext=='link2');
// -----------------------------------------------------------------------------
// <embed> test
$str = <<<HTML
<EMBED SRC="../graphics/sounds/1812over.mid" HEIGHT="60" WIDTH="144"></EMBED>
HTML;
$dom->load($str);
$e = $dom->find('embed', 0);
assert($e->src=='../graphics/sounds/1812over.mid');
assert($e->height=='60');
assert($e->width=='144');
assert($e==strtolower($str));
// -----------------------------------------------------------------------------
// <pre> test
$str = <<<HTML
<div class="class0" id="id0" >
<pre>
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
</pre>
</div>
HTML;
$dom->load($str);
//assert(count($dom->find('input'))==0);
// -----------------------------------------------------------------------------
// <code> test
$str = <<<HTML
<div class="class0" id="id0" >
<CODE>
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
</CODE>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('code'))==1);
//assert(count($dom->find('input'))==0);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,103 @@
<?php
// $Rev: 130 $
// -----------------------------------------------------------------------------
error_reporting(E_ALL);
include_once('../../simple_html_dom_reader.php');
$filename = '../html/google.htm';
function dump_memory() {
echo 'peak: ' . number_format(memory_get_peak_usage(), 0, '.', ',') . ' bytes, end: ' . number_format(memory_get_usage(), 0, '.', ',') . " bytes<br>";
}
function stat_dom($dom) {
$count_text = 0;
$count_comm = 0;
$count_elem = 0;
$count_tag_end = 0;
foreach($dom->nodes as $n) {
if ($n->nodetype==HDOM_TYPE_TEXT)
++$count_text;
if ($n->nodetype==HDOM_TYPE_COMMENT)
++$count_comm;
if ($n->nodetype==HDOM_TYPE_ELEMENT)
++$count_elem;
if ($n->nodetype==HDOM_TYPE_ENDTAG)
++$count_tag_end;
}
echo 'Total: '. count($dom->nodes).', Text: '.$count_text.', Commnet: '.$count_comm.', Tag: '.$count_elem.', End Tag: '.$count_tag_end.'<br>';
}
echo 'init ' . number_format(memory_get_usage(), 0, '.', ',') . " bytes";
echo '<br><br>[load file]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$str = file_get_contents($filename);
unset($str);
dump_memory();
}
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
$str = file_get_contents($filename);
echo '<br><br>[multi objects str_get_dom clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$dom = str_get_dom($str);
//stat_dom($dom);
$dom->clear();
unset($dom);
dump_memory();
flush();
}
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
echo '<br><br>[multi objects file_get_dom clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$dom = file_get_dom($filename);
//stat_dom($dom);
$dom->clear();
unset($dom);
dump_memory();
flush();
}
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
echo '<br><br>[one object]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
$dom = new simple_html_dom;
for($i=0; $i<3; ++$i) {
$dom->load_file($filename);
$dom->clear();
dump_memory();
}
unset($dom);
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
echo '<br><br>[multi objects without clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
echo '------------------------------------------<br>';
flush();
for($i=0; $i<3; ++$i) {
$dom = file_get_dom($filename);
dump_memory();
}
echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
flush();
?>

@ -0,0 +1,38 @@
<?php
// $Rev: 130 $
// -----------------------------------------------------------------------------
error_reporting(E_ALL);
include_once('../../simple_html_dom_reader.php');
$all = 0;
$min = 10000;
$max = 0;
$count = 20;
$str = file_get_contents('../html/google.htm');
$dom = new simple_html_dom;
for ($i=0; $i<$count; ++$i) {
$start = microtime();
$dom->load($str, false);
list($eu, $es) = explode(' ', microtime());
list($bu, $bs) = explode(' ', $start);
if (((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000 > $max)
$max = ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
if (((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000 < $min)
$min = ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
$all += ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
echo sprintf('(%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br>';
$dom->clear();
}
echo '<br>-------------------------<br>';
echo 'min: ' . $min . '<br>';
echo 'max: ' . $max . '<br>';
echo '<br>avg: ' . $all/$count . '<br>';
?>

@ -0,0 +1,584 @@
<?php
// $Rev: 130 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../../simple_html_dom_reader.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// "\t" or "\n" in tag test
// std selector test 1
$str = <<<HTML
<img
class="class0" id="id0" src="src0">
<img
class="class1" id="id1" src="src1">
<img class="class2" id="id2" src="src2">
HTML;
$dom->load($str);
$e = $dom->find('img');
assert(count($e)==3);
// -----------------------------------------------------------------------------
// std selector test
$str = <<<HTML
<img class="class0" id="id0" src="src0">
<img class="class1" id="id1" src="src1">
<img class="class2" id="id2" src="src2">
HTML;
$dom->load($str);
// -----------------------------------------------
// all
//$e = $dom->find('*');
//assert(count($e)==3);
// -----------------------------------------------
// tag
assert(count($dom->find('img'))==3);
// -----------------------------------------------
// class
$es = $dom->find('img.class0');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('.class0');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
// -----------------------------------------------
// id
$es = $dom->find('img#id1');
assert(count($es)==1);
assert($es[0]->src=='src1');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class1" id="id1" src="src1">');
$es = $dom->find('#id2');
assert(count($es)==1);
assert($es[0]->src=='src2');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class2" id="id2" src="src2">');
// -----------------------------------------------
// attr
$es = $dom->find('img[src="src0"]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('img[src=src0]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('[src=src0]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('[src="src0"]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
// -----------------------------------------------
// text
$str = <<<HTML
<b>text1</b><b>text2</b>
HTML;
$dom->load($str);
$es = $dom->find('text');
assert(count($es)==2);
assert($es[0]->innertext=='text1');
assert($es[0]->outertext=='text1');
assert($es[0]->plaintext=='text1');
assert($es[1]->innertext=='text2');
assert($es[1]->outertext=='text2');
assert($es[1]->plaintext=='text2');
$str = <<<HTML
<b>text1</b><b>text2</b>
HTML;
$dom->load($str);
$es = $dom->find('b text');
assert(count($es)==2);
assert($es[0]->innertext=='text1');
assert($es[0]->outertext=='text1');
assert($es[0]->plaintext=='text1');
assert($es[1]->innertext=='text2');
assert($es[1]->outertext=='text2');
assert($es[1]->plaintext=='text2');
// -----------------------------------------------
// xml namespace test
$str = <<<HTML
<bw:bizy id="date">text</bw:bizy>
HTML;
$dom->load($str);
$es = $dom->find('bw:bizy');
assert(count($es)==0);
// -----------------------------------------------
// user defined tag name test
$str = <<<HTML
<div_test id="1">text</div_test>
HTML;
$dom->load($str);
$es = $dom->find('div_test');
assert(count($es)==1);
assert($es[0]->id=='1');
// -----------------------------------------------
$str = <<<HTML
<div-test id="1">text</div-test>
HTML;
$dom->load($str);
$es = $dom->find('div-test');
assert(count($es)==1);
assert($es[0]->id=='1');
// -----------------------------------------------
$str = <<<HTML
<div::test id="1">text</div::test>
HTML;
$dom->load($str);
$es = $dom->find('div::test');
assert(count($es)==0);
// -----------------------------------------------
// find all occurrences of id="1" regardless of the tag
$str = <<<HTML
<img class="class0" id="1" src="src0">
<img class="class1" id="2" src="src1">
<div class="class2" id="1">ok</div>
HTML;
$dom->load($str);
$es = $dom->find('[id=1]');
assert(count($es)==2);
assert($es[0]->tag=='img');
assert($es[1]->tag=='div');
// -----------------------------------------------------------------------------
// multiple selector test
$str = <<<HTML
<div class="class0" id="id0" >
<div class="class1" id="id1">
<div class="class2" id="id2">ok</div>
</div>
</div>
HTML;
$dom->load($str);
$es = $dom->find('div');
assert(count($es)==3);
assert($es[0]->id=='id0');
assert($es[1]->id=='id1');
assert($es[2]->id=='id2');
$es = $dom->find('div div');
assert(count($es)==2);
assert($es[0]->id=='id1');
assert($es[1]->id=='id2');
$es = $dom->find('div div div');
assert(count($es)==1);
assert($es[0]->id=='id2');
// -----------------------------------------------------------------------------
// multiple selector test 2
$str = <<<HTML
<table>
<tr>
<td>0</td>
<td>1</td>
</tr>
</table>
<table>
<tr>
<td>2</td>
<td>3</td>
</tr>
</table>
HTML;
$dom->load($str);
$es = $dom->find('table td');
assert(count($es)==4);
assert($es[0]->innertext=='0');
assert($es[1]->innertext=='1');
assert($es[2]->innertext=='2');
assert($es[3]->innertext=='3');
// -----------------------------------------------------------------------------
// multiple selector test 3
$str = <<<HTML
<table>
<tr>
<td>
<table class="hello">
<tr>
<td>0</td>
<td>1</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="hello">
<tr>
<td>2</td>
<td>3</td>
</tr>
</table>
HTML;
$dom = str_get_dom($str);
$es = $dom->find('table.hello td');
assert(count($es)==4);
assert($es[0]->innertext=='0');
assert($es[1]->innertext=='1');
assert($es[2]->innertext=='2');
assert($es[3]->innertext=='3');
// -----------------------------------------------------------------------------
// nested selector test
$str = <<<HTML
<ul>
<li>0</li>
<li>1</li>
</ul>
<ul>
<li>2</li>
<li>3</li>
</ul>
HTML;
$dom = str_get_dom($str);
$es= $dom->find('ul');
assert(count($es)==2);
foreach($es as $n) {
$li = $n->find('li');
assert(count($li)==2);
}
$es= $dom->find('li');
assert(count($es)==4);
assert($es[0]->innertext=='0');
assert($es[1]->innertext=='1');
assert($es[2]->innertext=='2');
assert($es[3]->innertext=='3');
assert($es[0]->outertext=='<li>0</li>');
assert($es[1]->outertext=='<li>1</li>');
assert($es[2]->outertext=='<li>2</li>');
assert($es[3]->outertext=='<li>3</li>');
$counter = 0;
foreach($dom->find('ul') as $ul) {
foreach($ul->find('li') as $li) {
assert($li->innertext=="$counter");
assert($li->outertext=="<li>$counter</li>");
++$counter;
}
}
// -----------------------------------------------------------------------------
// [attribute=value] selector
$str = <<<HTML
<input type="radio" name="newsletter" value="Hot Fuzz" />
<input type="radio" name="newsletters" value="Cold Fusion" />
<input type="radio" name="accept" value="Evil Plans" />
HTML;
$dom->load($str);
$es = $dom->find('[name=newsletter]');
assert(count($es)==1);
assert($es[0]->name=='newsletter');
assert($es[0]->value=='Hot Fuzz');
assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz">');
$es = $dom->find('[name="newsletter"]');
assert(count($es)==1);
assert($es[0]->name=='newsletter');
assert($es[0]->value=='Hot Fuzz');
assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz">');
// -----------------------------------------------------------------------------
// [attribute!=value] selector
$str = <<<HTML
<input type="radio" name="newsletter" value="Hot Fuzz" />
<input type="radio" name="newsletter" value="Cold Fusion" />
<input type="radio" name="accept" value="Evil Plans" />
HTML;
$dom->load($str);
$es = $dom->find('[name!=newsletter]');
assert(count($es)==1);
assert($es[0]->name=='accept');
assert($es[0]->value=='Evil Plans');
assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans">');
$es = $dom->find('[name!="newsletter"]');
assert(count($es)==1);
assert($es[0]->name=='accept');
assert($es[0]->value=='Evil Plans');
assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans">');
$es = $dom->find("[name!='newsletter']");
assert(count($es)==1);
assert($es[0]->name=='accept');
assert($es[0]->value=='Evil Plans');
assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans">');
// -----------------------------------------------------------------------------
// [attribute^=value] selector
$str = <<<HTML
<input name="newsletter" />
<input name="milkman" />
<input name="newsboy" />
HTML;
$dom->load($str);
$es = $dom->find('[name^=news]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter">');
assert($es[1]->name=='newsboy');
assert($es[1]->outertext=='<input name="newsboy">');
$es = $dom->find('[name^="news"]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter">');
assert($es[1]->name=='newsboy');
assert($es[1]->outertext=='<input name="newsboy">');
// -----------------------------------------------------------------------------
// [attribute$=value] selector
$str = <<<HTML
<input name="newsletter" />
<input name="milkman" />
<input name="jobletter" />
HTML;
$dom->load($str);
$es = $dom->find('[name$=letter]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter">');
assert($es[1]->name=='jobletter');
assert($es[1]->outertext=='<input name="jobletter">');
$es = $dom->find('[name$="letter"]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter">');
assert($es[1]->name=='jobletter');
assert($es[1]->outertext=='<input name="jobletter">');
// -----------------------------------------------------------------------------
// [attribute*=value] selector
$str = <<<HTML
<input name="man-news" />
<input name="milkman" />
<input name="letterman2" />
<input name="newmilk" />
<div class="foo hello bar"></div>
<div class="foo bar hello"></div>
<div class="hello foo bar"></div>
HTML;
$dom->load($str);
$es = $dom->find('[name*=man]');
assert(count($es)==3);
assert($es[0]->name=='man-news');
assert($es[0]->outertext=='<input name="man-news">');
assert($es[1]->name=='milkman');
assert($es[1]->outertext=='<input name="milkman">');
assert($es[2]->name=='letterman2');
assert($es[2]->outertext=='<input name="letterman2">');
$es = $dom->find('[name*="man"]');
assert(count($es)==3);
assert($es[0]->name=='man-news');
assert($es[0]->outertext=='<input name="man-news">');
assert($es[1]->name=='milkman');
assert($es[1]->outertext=='<input name="milkman">');
assert($es[2]->name=='letterman2');
assert($es[2]->outertext=='<input name="letterman2">');
$es = $dom->find('[class*=hello]');
assert($es[0]->outertext=='<div class="foo hello bar"></div>');
assert($es[1]->outertext=='<div class="foo bar hello"></div>');
assert($es[2]->outertext=='<div class="hello foo bar"></div>');
// -----------------------------------------------------------------------------
// Testcase for '[]' names element
// normal checkbox
$str = <<<HTML
<input type="checkbox" name="news" value="foo" />
<input type="checkbox" name="news" value="bar">
<input type="checkbox" name="news" value="baz" />
HTML;
$dom->load($str);
$es = $dom->find('[name=news]');
assert(count($es)==3);
assert($es[0]->name=='news');
assert($es[0]->value=='foo');
assert($es[1]->name=='news');
assert($es[1]->value=='bar');
assert($es[2]->name=='news');
assert($es[2]->value=='baz');
// -----------------------------------------------------------------------------
// with '[]' names checkbox
$str = <<<HTML
<input type="checkbox" name="news[]" value="foo" />
<input type="checkbox" name="news[]" value="bar">
<input type="checkbox" name="news[]" value="baz" />
HTML;
$dom->load($str);
$es = $dom->find('[name=news[]]');
assert(count($es)==3);
assert($es[0]->name=='news[]');
assert($es[0]->value=='foo');
assert($es[1]->name=='news[]');
assert($es[1]->value=='bar');
assert($es[2]->name=='news[]');
assert($es[2]->value=='baz');
// -----------------------------------------------------------------------------
// with '[]' names checkbox 2
$str = <<<HTML
<input type="checkbox" name="news[foo]" value="foo" />
<input type="checkbox" name="news[bar]" value="bar">
HTML;
$dom->load($str);
$es = $dom->find('[name=news[foo]]');
assert(count($es)==1);
assert($es[0]->name=='news[foo]');
assert($es[0]->value=='foo');
// -----------------------------------------------------------------------------
// regular expression syntax escaping
$str = <<<HTML
<div>
<a href="image/one.png">one</a>
<a href="image/two.jpg">two</a>
<a href="/favorites/aaa">three (text)</a>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('a[href^="image/"]'))==2);
assert(count($dom->find('a[href*="/favorites/"]'))==1);
// -----------------------------------------------------------------------------
// multiple class test
$str = <<<HTML
<div class="hello">should verify</div>
<div class="foo hello bar">should verify</div>
<div class="foo bar hello">should verify</div>
<div class="hello foo bar">should verify</div>
<div class="helloworld">should not verify</div>
<div class="worldhello">should not verify</div>
<div class="worldhelloworld">should not verify</div>
HTML;
$dom->load($str);
$es = $dom->find('[class="hello"],[class*="hello "],[class*=" hello"]');
assert(count($es)==4);
assert($es[0]->class=='hello');
assert($es[1]->class=='foo hello bar');
assert($es[2]->class=='foo bar hello');
assert($es[3]->class=='hello foo bar');
$es = $dom->find('.hello');
assert(count($es)==4);
assert($es[0]->class=='hello');
assert($es[1]->class=='foo hello bar');
assert($es[2]->class=='foo bar hello');
assert($es[3]->class=='hello foo bar');
// -----------------------------------------------------------------------------
// multiple class test 2
$str = <<<HTML
<div class="aa bb"></div>
HTML;
$dom->load($str);
assert(count($dom->find('[class=aa]'))==1);
assert(count($dom->find('[class=bb]'))==1);
assert(count($dom->find('[class="aa bb"]'))==1);
assert(count($dom->find('[class=aa], [class=bb]'))==1);
// -----------------------------------------------------------------------------
// multiple selector test
$str = <<<HTML
<p>aaa</p>
<b>bbb</b>
<i>ccc</i>
HTML;
$dom->load($str);
$es = $dom->find('p,b,i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p, b, i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p, b , i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p ,b ,i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('b,p,i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('i,b,p');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p,b,i,p,b');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
// -----------------------------------------------------------------------------
// multiple selector test 2
$str = <<<HTML
<img title="aa" src="src">
<a href="href" title="aa"></a>
HTML;
$dom->load($str);
assert(count($dom->find('a[title], img[title]'))==2);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,742 @@
<?php
// $Rev: 172 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// "\t" or "\n" in tag test
$str = <<<HTML
<img
class="class0" id="id0" src="src0">
<img
class="class1" id="id1" src="src1">
<img class="class2" id="id2" src="src2">
HTML;
$dom->load($str);
$e = $dom->find('img');
assert(count($e)==3);
// -----------------------------------------------------------------------------
// std selector test
$str = <<<HTML
<div>
<img class="class0" id="id0" src="src0">
<img class="class1" id="id1" src="src1">
<img class="class2" id="id2" src="src2">
</div>
HTML;
$dom->load($str);
// -----------------------------------------------
// wildcard
assert(count($dom->find('*'))==1);
assert(count($dom->find('div *'))==3);
assert(count($dom->find('div img *'))==0);
assert(count($dom->find(' * '))==1);
assert(count($dom->find(' div * '))==3);
assert(count($dom->find(' div img *'))==0);
// -----------------------------------------------
// tag
assert(count($dom->find('img'))==3);
assert(count($dom->find('text'))==4);
// -----------------------------------------------
// class
$es = $dom->find('img.class0');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('.class0');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
// -----------------------------------------------
// index
assert($dom->find('img', 0)->src=='src0');
assert($dom->find('img', 1)->src=='src1');
assert($dom->find('img', 2)->src=='src2');
assert($dom->find('img', -3)->src=='src0');
assert($dom->find('img', -2)->src=='src1');
assert($dom->find('img', -1)->src=='src2');
// -----------------------------------------------
// id
$es = $dom->find('img#id1');
assert(count($es)==1);
assert($es[0]->src=='src1');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class1" id="id1" src="src1">');
$es = $dom->find('#id2');
assert(count($es)==1);
assert($es[0]->src=='src2');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class2" id="id2" src="src2">');
// -----------------------------------------------
// attr
$es = $dom->find('img[src="src0"]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('img[src=src0]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
// -----------------------------------------------------------------------------
// wildcard
$es = $dom->find('*[src]');
assert(count($es)==3);
$es = $dom->find('*[src=*]');
assert(count($es)==3);
$es = $dom->find('*[alt=*]');
assert(count($es)==0);
$es = $dom->find('*[src="src0"]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('*[src=src0]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('[src=src0]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('[src="src0"]');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
$es = $dom->find('*#id1');
assert(count($es)==1);
assert($es[0]->src=='src1');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class1" id="id1" src="src1">');
$es = $dom->find('*.class0');
assert(count($es)==1);
assert($es[0]->src=='src0');
assert($es[0]->innertext=='');
assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
// -----------------------------------------------------------------------------
// text
$str = <<<HTML
<b>text1</b><b>text2</b>
HTML;
$dom->load($str);
$es = $dom->find('text');
assert(count($es)==2);
assert($es[0]->innertext=='text1');
assert($es[0]->outertext=='text1');
assert($es[0]->plaintext=='text1');
assert($es[1]->innertext=='text2');
assert($es[1]->outertext=='text2');
assert($es[1]->plaintext=='text2');
$str = <<<HTML
<b>text1</b><b>text2</b>
HTML;
$dom->load($str);
$es = $dom->find('b text');
assert(count($es)==2);
assert($es[0]->innertext=='text1');
assert($es[0]->outertext=='text1');
assert($es[0]->plaintext=='text1');
assert($es[1]->innertext=='text2');
assert($es[1]->outertext=='text2');
assert($es[1]->plaintext=='text2');
// -----------------------------------------------------------------------------
// xml namespace test
$str = <<<HTML
<bw:bizy id="date">text</bw:bizy>
HTML;
$dom->load($str);
$es = $dom->find('bw:bizy');
assert(count($es)==1);
assert($es[0]->id=='date');
// -----------------------------------------------------------------------------
// user defined tag name test
$str = <<<HTML
<div_test id="1">text</div_test>
HTML;
$dom->load($str);
$es = $dom->find('div_test');
assert(count($es)==1);
assert($es[0]->id=='1');
// -----------------------------------------------
$str = <<<HTML
<div-test id="1">text</div-test>
HTML;
$dom->load($str);
$es = $dom->find('div-test');
assert(count($es)==1);
assert($es[0]->id=='1');
// -----------------------------------------------
$str = <<<HTML
<div::test id="1">text</div::test>
HTML;
$dom->load($str);
$es = $dom->find('div::test');
assert(count($es)==1);
assert($es[0]->id=='1');
// -----------------------------------------------
// find all occurrences of id="1" regardless of the tag
$str = <<<HTML
<img class="class0" id="1" src="src0">
<img class="class1" id="2" src="src1">
<div class="class2" id="1">ok</div>
HTML;
$dom->load($str);
$es = $dom->find('[id=1]');
assert(count($es)==2);
assert($es[0]->tag=='img');
assert($es[1]->tag=='div');
// -----------------------------------------------------------------------------
// multiple selector test
$str = <<<HTML
<div class="class0" id="id0" ><div class="class1" id="id1"><div class="class2" id="id2">ok</div><div style="st1 st2" id="id3"><span class="id4">ok</span></div></div></div>
HTML;
$dom->load($str);
$es = $dom->find('div');
assert(count($es)==4);
assert($es[0]->id=='id0');
assert($es[1]->id=='id1');
assert($es[2]->id=='id2');
$es = $dom->find('div div');
assert(count($es)==3);
assert($es[0]->id=='id1');
assert($es[1]->id=='id2');
$es = $dom->find('div div div');
assert(count($es)==2);
assert($es[0]->id=='id2');
$es = $dom->find('.class0 .class1 .class2');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('#id0 #id1 #id2');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('div[id=id0] div[id=id1] div[id=id2]');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('div[id="id0"] div[id="id1"] div[id="id2"]');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('div[id=id0] div[id="id1"] div[id="id2"]');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('div[id="id0"] div[id=id1] div[id="id2"]');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('div[id="id0"] div[id="id1"] div[id=id2]');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find("div[id='id0'] div[id='id1'] div[id='id2']");
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('[id=id0] [id=id1] [id=id2]');
assert(count($es)==1);
assert($es[0]->id=='id2');
$es = $dom->find('[id] [id] [id]');
assert(count($es)==2);
assert($es[0]->id=='id2');
assert($es[1]->id=='id3');
$es = $dom->find('[id=id0] [id=id1] [id=id3]');
assert(count($es)==1);
assert($es[0]->id=='id3');
$es = $dom->find('[id=id0] [id=id1] [style="st1 st2"]');
assert(count($es)==1);
assert($es[0]->id=='id3');
$es = $dom->find('[id=id0] [id=id1] [style=st1 st2]');
assert(count($es)==1);
assert($es[0]->id=='id3');
$es = $dom->find('[id=id0] [id=id1] [style=st1 st2] span[class=id4]');
assert(count($es)==1);
assert($es[0]->innertext=='ok');
$es = $dom->find('[id=id0] [id=id1] [style="st1 st2"] span[class="id4"]');
assert(count($es)==1);
assert($es[0]->innertext=='ok');
// -----------------------------------------------
$str = <<<HTML
<table>
<tr>
<td>0</td>
<td>1</td>
</tr>
</table>
<table>
<tr>
<td>2</td>
<td>3</td>
</tr>
</table>
HTML;
$dom->load($str);
$es = $dom->find('table td');
assert(count($es)==4);
assert($es[0]->innertext=='0');
assert($es[1]->innertext=='1');
assert($es[2]->innertext=='2');
assert($es[3]->innertext=='3');
// -----------------------------------------------------------------------------
// multiple selector test 3
$str = <<<HTML
<table>
<tr>
<td>
<table class="hello">
<tr>
<td>0</td>
<td>1</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="hello">
<tr>
<td>2</td>
<td>3</td>
</tr>
</table>
HTML;
$dom = str_get_html($str);
$es = $dom->find('table.hello td');
assert(count($es)==4);
assert($es[0]->innertext=='0');
assert($es[1]->innertext=='1');
assert($es[2]->innertext=='2');
assert($es[3]->innertext=='3');
// -----------------------------------------------------------------------------
// nested selector test
$str = <<<HTML
<ul>
<li>0</li>
<li>1</li>
</ul>
<ul>
<li>2</li>
<li>3</li>
</ul>
HTML;
$dom = str_get_html($str);
$es= $dom->find('ul');
assert(count($es)==2);
foreach($es as $n) {
$li = $n->find('li');
assert(count($li)==2);
}
$es= $dom->find('li');
assert(count($es)==4);
assert($es[0]->innertext=='0');
assert($es[1]->innertext=='1');
assert($es[2]->innertext=='2');
assert($es[3]->innertext=='3');
assert($es[0]->outertext=='<li>0</li>');
assert($es[1]->outertext=='<li>1</li>');
assert($es[2]->outertext=='<li>2</li>');
assert($es[3]->outertext=='<li>3</li>');
$counter = 0;
foreach($dom->find('ul') as $ul) {
foreach($ul->find('li') as $li) {
assert($li->innertext=="$counter");
assert($li->outertext=="<li>$counter</li>");
++$counter;
}
}
// -----------------------------------------------------------------------------
// [attribute=value] selector
$str = <<<HTML
<input type="radio" name="newsletter" value="Hot Fuzz" />
<input type="radio" name="newsletters" value="Cold Fusion" />
<input type="radio" name="accept" value="Evil Plans" />
HTML;
$dom->load($str);
$es = $dom->find('[name=newsletter]');
assert(count($es)==1);
assert($es[0]->name=='newsletter');
assert($es[0]->value=='Hot Fuzz');
assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz" />');
$es = $dom->find('[name="newsletter"]');
assert(count($es)==1);
assert($es[0]->name=='newsletter');
assert($es[0]->value=='Hot Fuzz');
assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz" />');
// -----------------------------------------------------------------------------
// [attribute!=value] selector
$str = <<<HTML
<input type="radio" name="newsletter" value="Hot Fuzz" />
<input type="radio" name="newsletter" value="Cold Fusion" />
<input type="radio" name="accept" value="Evil Plans" />
HTML;
$dom->load($str);
$es = $dom->find('[name!=newsletter]');
assert(count($es)==1);
assert($es[0]->name=='accept');
assert($es[0]->value=='Evil Plans');
assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans" />');
$es = $dom->find('[name!="newsletter"]');
assert(count($es)==1);
assert($es[0]->name=='accept');
assert($es[0]->value=='Evil Plans');
assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans" />');
$es = $dom->find("[name!='newsletter']");
assert(count($es)==1);
assert($es[0]->name=='accept');
assert($es[0]->value=='Evil Plans');
assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans" />');
// -----------------------------------------------------------------------------
// [attribute^=value] selector
$str = <<<HTML
<input name="newsletter" />
<input name="milkman" />
<input name="newsboy" />
HTML;
$dom->load($str);
$es = $dom->find('[name^=news]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter" />');
assert($es[1]->name=='newsboy');
assert($es[1]->outertext=='<input name="newsboy" />');
$es = $dom->find('[name^="news"]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter" />');
assert($es[1]->name=='newsboy');
assert($es[1]->outertext=='<input name="newsboy" />');
// -----------------------------------------------------------------------------
// [attribute$=value] selector
$str = <<<HTML
<input name="newsletter" />
<input name="milkman" />
<input name="jobletter" />
HTML;
$dom->load($str);
$es = $dom->find('[name$=letter]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter" />');
assert($es[1]->name=='jobletter');
assert($es[1]->outertext=='<input name="jobletter" />');
$es = $dom->find('[name$="letter"]');
assert(count($es)==2);
assert($es[0]->name=='newsletter');
assert($es[0]->outertext=='<input name="newsletter" />');
assert($es[1]->name=='jobletter');
assert($es[1]->outertext=='<input name="jobletter" />');
// -----------------------------------------------------------------------------
// [attribute*=value] selector
$str = <<<HTML
<input name="man-news" />
<input name="milkman" />
<input name="letterman2" />
<input name="newmilk" />
<div class="foo hello bar"></div>
<div class="foo bar hello"></div>
<div class="hello foo bar"></div>
HTML;
$dom->load($str);
$es = $dom->find('[name*=man]');
assert(count($es)==3);
assert($es[0]->name=='man-news');
assert($es[0]->outertext=='<input name="man-news" />');
assert($es[1]->name=='milkman');
assert($es[1]->outertext=='<input name="milkman" />');
assert($es[2]->name=='letterman2');
assert($es[2]->outertext=='<input name="letterman2" />');
$es = $dom->find('[name*="man"]');
assert(count($es)==3);
assert($es[0]->name=='man-news');
assert($es[0]->outertext=='<input name="man-news" />');
assert($es[1]->name=='milkman');
assert($es[1]->outertext=='<input name="milkman" />');
assert($es[2]->name=='letterman2');
assert($es[2]->outertext=='<input name="letterman2" />');
$es = $dom->find('[class*=hello]');
assert($es[0]->outertext=='<div class="foo hello bar"></div>');
assert($es[1]->outertext=='<div class="foo bar hello"></div>');
assert($es[2]->outertext=='<div class="hello foo bar"></div>');
// -----------------------------------------------------------------------------
// Testcase for '[]' names element
// normal checkbox
$str = <<<HTML
<input type="checkbox" name="news" value="foo" />
<input type="checkbox" name="news" value="bar">
<input type="checkbox" name="news" value="baz" />
HTML;
$dom->load($str);
$es = $dom->find('[name=news]');
assert(count($es)==3);
assert($es[0]->name=='news');
assert($es[0]->value=='foo');
assert($es[1]->name=='news');
assert($es[1]->value=='bar');
assert($es[2]->name=='news');
assert($es[2]->value=='baz');
// -----------------------------------------------------------------------------
// with '[]' names checkbox
$str = <<<HTML
<input type="checkbox" name="news[]" value="foo" />
<input type="checkbox" name="news[]" value="bar">
<input type="checkbox" name="news[]" value="baz" />
HTML;
$dom->load($str);
$es = $dom->find('[name=news[]]');
assert(count($es)==3);
assert($es[0]->name=='news[]');
assert($es[0]->value=='foo');
assert($es[1]->name=='news[]');
assert($es[1]->value=='bar');
assert($es[2]->name=='news[]');
assert($es[2]->value=='baz');
// -----------------------------------------------------------------------------
// with '[]' names checkbox 2
$str = <<<HTML
<input type="checkbox" name="news[foo]" value="foo" />
<input type="checkbox" name="news[bar]" value="bar">
HTML;
$dom->load($str);
$es = $dom->find('[name=news[foo]]');
assert(count($es)==1);
assert($es[0]->name=='news[foo]');
assert($es[0]->value=='foo');
// -----------------------------------------------------------------------------
// with '[]' names 3
$str = <<<HTML
<div name="div[]">
<input type="checkbox" name="checkbox[]" value="foo" />
</div>
HTML;
$dom->load($str);
$es = $dom->find('div[name=div[]] input[name=checkbox[]]');
assert(count($es)==1);
assert($es[0]->value=='foo');
// -----------------------------------------------------------------------------
// regular expression
$str = <<<HTML
<div>
<a href="image/one.png">one</a>
<a href="image/two.jpg">two</a>
<a href="/favorites/aaa">three (text)</a>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('a[href^="image/"]'))==2);
assert(count($dom->find('a[href*="/favorites/"]'))==1);
$str = <<<HTML
<html>
<body>
<div id="news-id-123">okok</div>
</bod>
</html>
HTML;
$dom->load($str);
assert(count($dom->find('div[id*=news-id-[0-9]+]'))==1);
assert(count($dom->find('div[id*=/news-id-[0-9]+/i]'))==1);
// -----------------------------------------------------------------------------
// multiple class test
$str = <<<HTML
<div class="hello">should verify</div>
<div class="foo hello bar">should verify</div>
<div class="foo bar hello">should verify</div>
<div class="hello foo bar">should verify</div>
<div class="helloworld">should not verify</div>
<div class="worldhello">should not verify</div>
<div class="worldhelloworld">should not verify</div>
HTML;
$dom->load($str);
$es = $dom->find('[class="hello"],[class*="hello "],[class*=" hello"]');
assert(count($es)==4);
assert($es[0]->class=='hello');
assert($es[1]->class=='foo hello bar');
assert($es[2]->class=='foo bar hello');
assert($es[3]->class=='hello foo bar');
$es = $dom->find('.hello');
assert(count($es)==4);
assert($es[0]->class=='hello');
assert($es[1]->class=='foo hello bar');
assert($es[2]->class=='foo bar hello');
assert($es[3]->class=='hello foo bar');
// -----------------------------------------------
$str = <<<HTML
<div class="aa bb"></div>
HTML;
$dom->load($str);
assert(count($dom->find('[class=aa]'))==1);
assert(count($dom->find('[class=bb]'))==1);
assert(count($dom->find('[class="aa bb"]'))==1);
assert(count($dom->find('[class=aa], [class=bb]'))==1);
// -----------------------------------------------------------------------------
// multiple selector test
$str = <<<HTML
<p>aaa</p>
<b>bbb</b>
<i>ccc</i>
HTML;
$dom->load($str);
$es = $dom->find('p,b,i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p, b, i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p, b , i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p ,b ,i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('b,p,i');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('i,b,p');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
$es = $dom->find('p,b,i,p,b');
assert(count($es)==3);
assert($es[0]->tag=='p');
assert($es[1]->tag=='b');
assert($es[2]->tag=='i');
// -----------------------------------------------
$str = <<<HTML
<img title="aa" src="src">
<a href="href" title="aa"></a>
HTML;
$dom->load($str);
assert(count($dom->find('a[title], img[title]'))==2);
// -----------------------------------------------------------------------------
// elements that do NOT have the specified attribute
$str = <<<HTML
<img id="aa" src="src">
<img src="src">
HTML;
$dom->load($str);
assert(count($dom->find('img[!id]'))==1);
// -----------------------------------------------------------------------------
//js test
$str = <<<HTML
<a onMouseover="dropdownmenu(this, event, 'messagesmenu')" class="n" href="messagecenter.cfm?key=972489434">foo</a>
HTML;
$dom->load($str);
assert($dom->find('a[onMouseover="dropdownmenu(this, event, \'messagesmenu\')"]',0)->innertext=='foo');
assert($dom->find("a[onMouseover=dropdownmenu(this, event, 'messagesmenu')]",0)->innertext=='foo');
// -----------------------------------------------------------------------------
//dash test
$str = '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
$dom->load($str);
assert($dom->find('meta[http-equiv=content-type]', 0)->content==='text/html; charset=utf-8');
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,27 @@
<?php
// $Rev: 133 $
error_reporting(E_ALL);
include_once('../simple_html_dom.php');
$start = microtime();
list($bu, $bs) = explode(' ', $start);
$html = file_get_html('slickspeed.htm');
list($eu, $es) = explode(' ', microtime());
echo sprintf('parse (%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br><br>';
assert(count($html->find('#title'))==1);
assert(count($html->find('div'))==51);
assert(count($html->find('div[class]'))==51);
assert(count($html->find('div.example'))==43);
assert(count($html->find('div[class=example]'))==43);
assert(count($html->find('.note'))==14);
assert(count($html->find('div[class^=exa]'))==43);
assert(count($html->find('div[class$=mple]'))==43);
assert(count($html->find('div[class*=e]'))==50);
assert(count($html->find('div[class!=made_up]'))==51);
assert(count($html->find('p'))==324);
echo 'All pass!<br>';
?>

@ -0,0 +1,243 @@
<?php
// $Rev: 115 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// empty test
$str = '';
$dom->load($str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = null;
$dom->load($str);
assert($dom->save()==$str);
// -----------------------------------------------------------------------------
// text test
$str = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"></html>
HTML;
$dom->load($str);
assert(count($dom->find('unknown'))==1);
assert(count($dom->find('text'))==1);
// -----------------------------------------------------------------------------
// string quote test
$str = <<<HTML
<div class="class0" id="id0" >
okok<br>
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
<br/>
<div><input type=submit name="btnG2" value="go" onclick="goto('url1'+'\'')"/></div>
<input type=submit name="btnG2" value="go" onclick="goto('url2')"/>
<div><input type=submit name="btnG2" value="go" onclick='goto("url4"+"\"")'></div>
<br/>
</div>
HTML;
$dom->load($str);
$es = $dom->find('input');
assert(count($es)==4);
assert($es[0]->onclick=='goto("url0")');
assert($es[1]->onclick=="goto('url1'+'\'')");
assert($es[2]->onclick=="goto('url2')");
assert($es[3]->onclick=='goto("url4"+"\"")');
// -----------------------------------------------------------------------------
// clone test
$str = <<<HTML
<div class="class0" id="id0" >
okok<br>
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
<br/>
<div><input type=submit name="btnG2" value="go" onclick="goto('url1'+'\'')"/></div>
<input type=submit name="btnG2" value="go" onclick="goto('url2')"/>
<div><input type=submit name="btnG2" value="go" onclick='goto("url4"+"\"")'></div>
<br/>
</div>
HTML;
$dom->load($str);
$es = $dom->find('input');
assert(count($es)==4);
assert($es[0]->onclick=='goto("url0")');
assert($es[1]->onclick=="goto('url1'+'\'')");
assert($es[2]->onclick=="goto('url2')");
assert($es[3]->onclick=='goto("url4"+"\"")');
unset($es);
$dom2 = clone($dom);
$es = $dom2->find('input');
assert(count($es)==4);
assert($es[0]->onclick=='goto("url0")');
assert($es[1]->onclick=="goto('url1'+'\'')");
assert($es[2]->onclick=="goto('url2')");
assert($es[3]->onclick=='goto("url4"+"\"")');
// -----------------------------------------------
$str = <<<HTML
<div class='class0' id="id0" aa='aa' bb="bb" cc='"cc"' dd="'dd'"></div>
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------------------------------------
// monkey test
$str = <<<HTML
<
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<a
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<a<
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<<<<ab
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<<<<ab
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<<><<>ab
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
<abc
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
>
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------
// $str = <<<HTML
// <abc
// (<1 mol%)
// HTML;
// $dom->load($str);
// echo $dom;
// assert($dom==$str);
// assert($dom->save()==$str);
// -----------------------------------------------
$str = <<<HTML
(<1 mol%)
HTML;
$dom->load($str);
assert($dom==$str);
assert($dom->save()==$str);
// -----------------------------------------------------------------------------
// rnadom string test
function str_random($length)
{
$str = "";
srand((double)microtime()*1000000);
$char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$char_list .= "abcdefghijklmnopqrstuvwxyz";
$char_list .= "1234567890";
$char_list .= "<>!?[]%^&*()";
for($i=0; $i<$length; ++$i)
$str .= substr($char_list,(rand()%(strlen($char_list))), 1);
return $str;
}
for($i=0; $i<60; ++$i) {
$str = str_random($i);
//echo $str."\n<br>";
$dom->load($str, false);
//echo $dom->save()."\n<br>";
assert($dom==$str);
}
// -----------------------------------------------------------------------------
// lowercase test
$str = <<<HTML
<img class="class0" id="id0" src="src0">
HTML;
$dom->load($str);
assert(count($dom->find('img'))==1);
assert(count($dom->find('IMG'))==1);
assert(isset($dom->find('img', 0)->class));
assert(!isset($dom->find('img', 0)->CLASS));
assert($dom->find('img', 0)->class=='class0');
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<IMG CLASS="class0" ID="id0" SRC="src0">
HTML;
$dom->load($str);
assert(count($dom->find('img'))==1);
assert(count($dom->find('IMG'))==1);
assert(isset($dom->find('img', 0)->class));
assert(!isset($dom->find('img', 0)->CLASS));
assert($dom->find('img', 0)->class=='class0');
assert($dom==strtolower($str));
// -----------------------------------------------
$str = <<<HTML
<IMG CLASS="class0" ID="id0" SRC="src0">
HTML;
$dom->load($str, false);
assert(count($dom->find('img'))==0);
assert(count($dom->find('IMG'))==1);
assert(isset($dom->find('IMG', 0)->CLASS));
assert(!isset($dom->find('IMG', 0)->class));
assert($dom->find('IMG', 0)->CLASS=='class0');
assert($dom==$str);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,137 @@
<?php
// $Rev: 169 $
// -----------------------------------------------------------------------------
// setup
error_reporting(E_ALL);
require_once('../simple_html_dom.php');
$dom = new simple_html_dom;
// -----------------------------------------------------------------------------
// comments test
$str = <<<HTML
<div class="class0" id="id0" >
<!--
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
-->
</div>
HTML;
$dom->load($str);
assert(count($dom->find('input'))==0);
// -----------------------------------------------------------------------------
// <code> test
$str = <<<HTML
<div class="class0" id="id0" >
<CODE>
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
</CODE>
</div>
HTML;
$dom->load($str);
assert(count($dom->find('code'))==1);
assert(count($dom->find('input'))==0);
// -----------------------------------------------------------------------------
// <pre> & <code> test
$str = <<<HTML
<PRE><CODE CLASS=Java>
<input type=submit name="btnG" value="go" onclick='goto("url0")'>
</CODE></PRE>
HTML;
$dom->load($str);
assert(count($dom->find('pre'))==1);
assert(count($dom->find('input'))==0);
// -----------------------------------------------------------------------------
// <script> & <style> test
$str = <<<HTML
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test.js"/>
<style type="text/css">
@import url("style.css");
</style>
<script type="text/javascript">
var foo = "bar";
</script>
HTML;
$dom->load($str);
assert(count($dom->find('style'))==1);
assert(count($dom->find('script'))==3);
// -----------------------------------------------------------------------------
// php short tag test
$str = <<<HTML
<a href="<?=h('ok')?>">hello</a>
<input type=submit name="btnG" value="<?php echoh('ok')?>">
HTML;
$dom->load($str);
assert($dom->find('a', 0)->href==="<?=h('ok')?>");
assert($dom->find('input', 0)->value==="<?php echoh('ok')?>");
// -----------------------------------------------------------------------------
// noise stripping test
$str = <<<HTML
<!--
<img class="class0" id="id0" src="src0">-->
<img class="class1" id="id1" src="src1">
<!--<img class="class2" id="id2" src="src2">
-->
HTML;
$dom->load($str);
assert(count($dom->find('img'))==1);
assert($dom==$str);
// -----------------------------------------------
$str = <<<HTML
<script type="text/javascript" src="test1.js">ss</script>
<script type="text/javascript" src="test2.js"/>
<script type="text/javascript" src="test3.js" />
<script type="text/javascript" src="test4.js"
/>
<script type="text/javascript" src="test5.js"/>
<style>
@import url("style1.css");
</style>
<script>
var foo = "bar";
</script>
<style type="text/css">
@import url("style2.css");
</style>
<style>
div,td,.n a,.n a:visited{color:#000}.ts td,.tc{padding:0}.ts,.tb{border-collapse:collapse}.ti,.bl{display:inline}.ti{display:inline-table}.f,.m{color:#666}.flc,a.fl{color:#77c}a,.w,.q:visited,.q:active,.q,.b a,.b a:visited,.mblink:visited{color:#00c}a:visited{color:#551a8b}a:active{color:red}.t{background:#d5ddf3;
color:#000;
padding:5px 1px 4px}.bb{border-bottom:1px solid #36c}.bt{border-top:1px solid #36c}.j{width:34em}.h{color:#36c}.i{color:#a90a08}.a{color:green}.z{display:none}div.n{margin-top:1ex}.n a,.n .i{font-size:10pt}.n .i,.b a{font-weight:bold}.b a{font-size:12pt}.std{font-size:82%}#np,#nn,.nr,#logo span,.ch{cursor:pointer;cursor:hand}.ta{padding:3px 3px 3px 5px}#tpa2,#tpa3{padding-top:9px}#gbar{float:left;height:22px;padding-left:2px}.gbh,.gb2 div{border-top:1px solid #c9d7f1;
</style>
<!-- BEGIN ADVERTPRO ADVANCED CODE BLOCK -->
<script language="JavaScript" type="text/javascript">
<!--
document.write('<SCR'+'IPT src="zone?zid=159&pid=0&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'" language="JavaScript" type="text/javascript"></SCR'+'IPT>');
//-->
</script>
<!-- END ADVERTPRO ADVANCED CODE BLOCK -->
<script type="text/javascript">
var foo = "bar";
</script>
HTML;
$dom->load($str);
assert(count($dom->find('script'))==8);
assert(count($dom->find('style'))==3);
//echo "\n\n\n\n".$dom->save();
assert($dom==$str);
// -----------------------------------------------------------------------------
// tear down
$dom->clear();
unset($dom);
?>

@ -0,0 +1,24 @@
{
"name": "sunra/php-simple-html-dom-parser",
"type": "library",
"description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",
"keywords": ["html", "dom", "parser"],
"homepage": "https://github.com/sunra/php-simple-html-dom-parser",
"license": "MIT",
"authors": [
{
"homepage": "http://sourceforge.net/projects/simplehtmldom/"
},
{
"name": "Sunra",
"email": "sunra@yandex.ru",
"homepage": "https://github.com/sunra"
}
],
"require": {
"php": ">=5.3.2"
},
"autoload": {
"psr-0": { "Sunra\\PhpSimple\\HtmlDomParser": "Src/" }
}
}

@ -10,7 +10,6 @@ html {
}
body {
margin-bottom: 60px;
background-color: #383e4b;
/* The html and body elements cannot have any padding or margin. */
}
@ -202,6 +201,7 @@ footer .container .row {
.actions {
margin-top: 10px;
margin-bottom: 10px;
width:100%;
}
.actions form {
@ -6767,10 +6767,10 @@ header .navbar {
}
footer {
position: absolute;
/*position: absolute;
bottom: 0;
width: 100%;
height: 60px;
height: 60px;*/
background-color: #f5f5f5;
}

Loading…
Cancel
Save