Skip to content

Instantly share code, notes, and snippets.

@diversen
Last active July 8, 2017 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diversen/9d37104c0cdd89d964217562f01fc615 to your computer and use it in GitHub Desktop.
Save diversen/9d37104c0cdd89d964217562f01fc615 to your computer and use it in GitHub Desktop.
<?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