SilverStripe 2.4 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
Version: master
  • master
  • 3.1
  • 3.0
  • 2.4
  • tagfield

Packages

  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • publishers
    • reports
    • security
    • tasks
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • installer
  • None
  • PHP
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets

Classes

  • Aggregate
  • Aggregate_Relationship
  • ClassInfo
  • CSSContentParser
  • Extension
  • ManifestBuilder
  • Object
  • SS_Cache
  • TokenisedRegularExpression
  • ValidationResult
  • YamlFixture

Functions

  • _t
  • array_fill_keys
  • getClassFile
  • getSysTempDir
  • getTempFolder
  • increase_memory_limit_to
  • increase_time_limit_to
  • project
  • sapphire_autoload
  • singleton
  • stripslashes_recursively
  • translate_memstring

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
Extended by CSSContentParser
Package: sapphire\core
Located at sapphire/dev/CSSContentParser.php

Methods summary

public
# __construct( mixed $content )

Overrides

Object::__construct
public SimpleXMLElement
# getBySelector( String $selector )

Returns a number of SimpleXML elements that match the given CSS selector. Currently the selector engine only supports querying by tag, id, and class. See CSSContentParser::getByXpath() for a more direct selector syntax.

Returns a number of SimpleXML elements that match the given CSS selector. Currently the selector engine only supports querying by tag, id, and class. See CSSContentParser::getByXpath() for a more direct selector syntax.

Parameters

$selector
String
$selector

Returns

SimpleXMLElement
public SimpleXMLElement|false
# getByXpath( String $xpath )

Allows querying the content through XPATH selectors.

Allows querying the content through XPATH selectors.

Parameters

$xpath
String
$xpath SimpleXML compatible XPATH statement

Returns

SimpleXMLElement|false
public String
# selector2xpath( String $selector )

Converts a CSS selector into an equivalent xpath expression. Currently the selector engine only supports querying by tag, id, and class.

Converts a CSS selector into an equivalent xpath expression. Currently the selector engine only supports querying by tag, id, and class.

Parameters

$selector
String
$selector See CSSContentParser::getBySelector()

Returns

String
XPath expression

Methods inherited from Object

__call(), __toString(), 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

Comments

Comment policy: Please use comments for tips and corrections about the described functionality. Comments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant.
Use the Silverstripe Forum to ask questions.
blog comments powered by Disqus
SilverStripe 2.4 API Docs API documentation generated by ApiGen 2.8.0