Last active
July 8, 2017 22:36
-
-
Save diversen/9d37104c0cdd89d964217562f01fc615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// composer require symfony/css-selector | |
// Easy to use CSS selectors on XML and HTML docs. | |
use Symfony\Component\CssSelector\CssSelectorConverter; | |
include_once "vendor/autoload.php"; | |
// $xml = simplexml_load_file('test.xml'); | |
function querySelector($simple_xml, $query) { | |
$converter = new CssSelectorConverter(); | |
$res = $simple_xml->xpath($converter->toXPath($query)); | |
return $res; | |
} | |
// $res = querySelector($xml, 'css > tag > another'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment