https://github.com/r32/css-selector
xml-parser with position
https://github.com/r32/css-selector
css css-selector xml
Last synced: about 1 year ago
JSON representation
xml-parser with position
- Host: GitHub
- URL: https://github.com/r32/css-selector
- Owner: R32
- Created: 2017-08-02T17:23:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T16:09:16.000Z (almost 3 years ago)
- Last Synced: 2025-04-07T06:12:09.183Z (about 1 year ago)
- Topics: css, css-selector, xml
- Language: Haxe
- Homepage:
- Size: 132 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CSS Selector
--------
A css selector tool and a simple xml parser(Provides additional position information).
It's suitable for use in non-browsing environments.
example:
```haxe
import csss.xml.Xml;
using csss.Query;
class Main {
static function main() {
mymacro();
}
macro static function mymacro() {
var myxml = "bin/index.html";
var file = sys.io.File.getContent(myxml);
var body = Xml.parse(file).querySelector("body");
var x = body.querySelector("#t3 > li span");
trace(x != null ? x.toSimpleString() : x);
var a = body.querySelectorAll(".selector-test > :nth-child(2n+1)");
for (x in a) {
trace(x.toSimpleString());
}
var value = body.get("class");
if (value != "expected") {
var p = body.attrPos("class");
var pos = haxe.macro.PositionTools.make({
min: p,
max: p + value.length,
file: myxml
});
haxe.macro.Context.error("click this message to location where the error occurred.", pos);
}
return macro null;
}
}
```
### Issues
* [Insolvable] Do not suport escaped single/double quotes.
e.g: `a[title="hi \"name\"."]` will get a unexpected value.
### Changes
* `0.7.0`:
- removed uppercase
- Rewrote csss.Query again