Version: current

# Class CSSContentParser

CSSContentParser enables parsing & assertion running of HTML content via CSS selectors.

It works by converting the content to XHTML using tidy, rewriting the CSS selectors as XPath queries, and executing those using SimpeXML.

It was built to facilitate testing using PHPUnit and contains a number of assert methods that will throw PHPUnit assertion exception when applicable.

Tries to use the PHP Tidy extension (http://php.net/tidy), and falls back to the "tidy" CLI tool. If none of those exists, the string is parsed directly without sanitization.

  Object
  CSSContentParser

Package: sapphire\core
Located at sapphire/dev/CSSContentParser.php

## Methods summary

`public` | # `__construct( mixed $content )` #### Overrides `Object::__construct`
`public` | # `getBySelector( mixed $selector )` Returns a number of SimpleXML elements that match the given CSS selector. Currently the selector engine only supports querying by tag, id, and classs Returns a number of SimpleXML elements that match the given CSS selector. Currently the selector engine only supports querying by tag, id, and classs
`public` | # `selector2xpath( mixed $selector )` Converts a CSS selector into an equivalent xpath expression. Currently the selector engine only supports querying by tag, id, and classs Converts a CSS selector into an equivalent xpath expression. Currently the selector engine only supports querying by tag, id, and classs

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `defineMethods()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`protected mixed` | $simpleXML | #

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -