-
-
Notifications
You must be signed in to change notification settings - Fork 11
HTML mode and XML mode
Greg Bowler edited this page Mar 4, 2026
·
2 revisions
Translator defaults to HTML mode:
new Translator("[data-FOO='bar']");In HTML mode (htmlMode: true):
- Element names are treated case-insensitively.
- Attribute names are lowered for matching.
- Attribute values remain case-sensitive.
When querying XML, pass htmlMode: false and usually use prefix: "//".
$translator = new Translator(
"[data-FOO='bar']",
prefix: "//",
htmlMode: false
);In XML mode:
- Element names are case-sensitive.
- Attribute names are case-sensitive.
- Attribute values are case-sensitive.
For XML behaviour, load content as XML (load, loadXML, or loadXMLFile) rather than HTML loaders (loadHTML, loadHTMLFile), because HTML loaders normalise names.
Continue to prefixes and advanced usage.
PHP.GT/CssXPath is a separately maintained component of PHP.Gt/WebEngine.