2017 © Pedro Peláez
 

library csselectorparser

A Csselector Translator to PHP

image

kolter/csselectorparser

A Csselector Translator to PHP

  • Sunday, June 10, 2018
  • by Kolter
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Csselector PHP Translator

This library parse Csselector into PHP, I was doing an html parser and needed a Csselector parser to support finding elements with csselectors., (*1)

The symfony component converts CSS selectors to XPath expressions but that didn't work for me so I create this so I can use the component for differente purposes., (*2)

Instalation

use Kolter\CsselectorTranslator\CsselectorTranslator;

$query = "p.class1.class2.class3 > div[href^=https],img:first-child

$translator = new CsselectorTranslator();
$elements = $translator->parse();
// This will return an array of Element
echo $elements[0];
// Output: "p.class1.class2#id>div[href^=https],img"
// Element 0 is the p tag but the __toString() method will output the conection 
//between elements so it will show the whole selector
$element[0]->getClasses();
// Output: ['class1','class2']
$elements[0]->getId();
// Output: "id"

The Versions

10/06 2018

dev-master

9999999-dev https://github.com/Ozumas7/csselectortranslator

A Csselector Translator to PHP

  Sources   Download

GPL-3.0

The Requires

 

by Pablo Luna

translator csselector