📜 ⬆️ ⬇️

HTML parser jquery style

I stumbled upon such a useful class, fans of chained calls and jquery will like it very much!

PHP Simple HTML DOM Parser:
simplehtmldom.sourceforge.net

Examples:
// Find all anchors, returns a array of element objects
$ ret = $ html-> find ('a');
')
// Find (N) anchor, return element if not found (zero based)
$ ret = $ html-> find ('a', 0);

// Find all attribute id = foo
$ ret = $ html-> find ('div [id = foo]');

// Find all with the id attribute
$ ret = $ html-> find ('div [id]');

// Find all element has attribute id
$ ret = $ html-> find ('[id]');

// or
echo $ html-> getElementById ("div1") -> childNodes (1) -> childNodes (1) -> childNodes (2) -> getAttribute ('id');

simplehtmldom.sourceforge.net/manual.htm - documentation and more examples

Source: https://habr.com/ru/post/30781/


All Articles