Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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