PHP code example of badlamer / symfony-hybrid-xml-parser

1. Go to this page and download the library: Download badlamer/symfony-hybrid-xml-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

badlamer / symfony-hybrid-xml-parser example snippets



	use Symfony\Component\DomCrawler\Crawler;

	$parser = new HybridXMLParser;
	$parser
		// Вешаем обработчик на путь в XML
		->bind('/FictionBook/description/title-info/author', function(Crawler $author, $parser) {
			print_r($author);
		})
		// И ещё один
		->bind('/FictionBook/description/title-info/translator', function(Crawler $translator, $parser) {
			print_r($translator);
			// Так можно немедленно завершить парсинг
			$parser->stop();
		})
		// Запускаем
		->process('somebook.fb2')
		->process('anotherbook.fb2');