-
-
Notifications
You must be signed in to change notification settings - Fork 443
API Elements
Jaeger edited this page Oct 9, 2017
·
4 revisions
Based on phpQuery,see: phpQuery Wiki or jQuery Documentation
-
QL\Domements
* Examples
-
Properties
- [HTML Attributes]
-
Methods
- __construct * Arguments
- map * Arguments * Examples
- attrs * Arguments * Examples
- texts
- htmls * Examples
- getElements
- toReference
- documentFragment
- toRoot
- getDocumentIDRef
- getDocument
- getDOMDocument
- getDocumentID
- unloadDocument
- isHTML
- isXHTML
- isXML
- serialize
- serializeArray
- get
- getString
- getStrings
- newInstance
- find
- is
- filterCallback
- filter
- load
- trigger
- triggerHandler
- bind
- unbind
- change
- submit
- click
- wrapAllOld
- wrapAll
- wrapAllPHP
- wrap
- wrapPHP
- wrapInner
- wrapInnerPHP
- contents
- contentsUnwrap
- switchWith
- eq
- size
- length
- count
- end
- _clone
- replaceWithPHP
- replaceWith
- replaceAll
- remove
- markup
- markupOuter
- html
- xml
- htmlOuter
- xmlOuter
- php
- markupPHP
- markupOuterPHP
- children * Examples
- ancestors
- append
- appendPHP
- appendTo
- prepend
- prependPHP
- prependTo
- before
- beforePHP
- insertBefore
- after
- afterPHP
- insertAfter
- insert
- index
- slice
- reverse
- text
- plugin
- extend
- _next
- _prev
- prev
- prevAll
- nextAll
- siblings
- not
- add
- parent
- parents
- stack
- attr
- attrPHP
- removeAttr
- val
- andSelf
- addClass
- addClassPHP
- hasClass
- removeClass
- toggleClass
- _empty
- each
- callback
- data
- removeData
- rewind
- current
- key
- next
- valid
- offsetExists
- offsetGet
- offsetSet
- offsetUnset
- whois
- dump
- dumpWhois
- dumpLength
- dumpTree
- dumpDie
-
Properties
Class Elements
- Class name: Elements
- Namespace: QL\Dom
Traversing:
$queryList = QL\QueryList::get('https://github.com');
$queryList->find('a')->attr('href', 'newVal')->removeClass('className')->html('newHtml')->...
$queryList->find('div > p')->add('div > ul')->filter(':has(a)')->find('p:first')->nextAll()->andSelf()->...
$queryList->find('div.old')->replaceWith( $ql->find('div.new')->clone() )->appendTo('.trash')->prepend('Deleted')->...
GitHub login form:
$form = QueryList::get('https://github.com/login')->find('form');
$form->find('input[name=login]')->val('github user');
$form->find('input[name=password]')->val('github password');
$data = $form->serialize();
print_r($data);
$data = $form->serializeArray();
print_r($data);
//Gets the link address of the first image
$queryList->find('img')->src;
//equivalence
$queryList->find('img:eq(0)')->src;
//equivalence
$queryList->find('img')->eq(0)->src;
//Gets the abc attribute of the first image
$queryList->find('img')->abc;
//Gets the alt attribute of the second image
$queryList->find('img')->eq(1)->alt;
//equivalence
$queryList->find('img:eq(1)')->alt;
mixed QL\Dom\Elements::__construct($elements)
Elements constructor.
- Visibility: public
- $elements mixed
\Illuminate\Support\Collection QL\Dom\Elements::map($callback)
Iterating elements
- Visibility: public
- $callback mixed
$data = $queryList->find('img')->map(function($item){
return $item->alt;
});
print_r($data->all());
\Illuminate\Support\Collection QL\Dom\Elements::attrs($attr)
Gets the attributes of all the elements
- Visibility: public
- $attr mixed - <p>HTML attribute name</p>
// Get all the picture links
$data = $queryList->find('img')->attrs('src');
print_r($data->all());
\Illuminate\Support\Collection QL\Dom\Elements::texts()
Gets the text of all the elements
- Visibility: public
\Illuminate\Support\Collection QL\Dom\Elements::htmls()
Gets the html of all the elements
- Visibility: public
$data = $queryList->find('#one')->append('<div>append content</div>')->find('div')->htmls();
print_r($data->all());
\phpQueryObject QL\Dom\Elements::getElements()
- Visibility: public
QL\Dom\Elements::toReference()
- Visibility: public
QL\Dom\Elements::documentFragment()
- Visibility: public
QL\Dom\Elements::toRoot()
- Visibility: public
QL\Dom\Elements::getDocumentIDRef()
- Visibility: public
QL\Dom\Elements::getDocument()
- Visibility: public
QL\Dom\Elements::getDOMDocument()
- Visibility: public
QL\Dom\Elements::getDocumentID()
- Visibility: public
QL\Dom\Elements::unloadDocument()
- Visibility: public
QL\Dom\Elements::isHTML()
- Visibility: public
QL\Dom\Elements::isXHTML()
- Visibility: public
QL\Dom\Elements::isXML()
- Visibility: public
QL\Dom\Elements::serialize()
- Visibility: public
QL\Dom\Elements::serializeArray()
- Visibility: public
QL\Dom\Elements::get()
- Visibility: public
QL\Dom\Elements::getString()
- Visibility: public
QL\Dom\Elements::getStrings()
- Visibility: public
QL\Dom\Elements::newInstance()
- Visibility: public
QL\Dom\Elements::find()
- Visibility: public
QL\Dom\Elements::is()
- Visibility: public
QL\Dom\Elements::filterCallback()
- Visibility: public
QL\Dom\Elements::filter()
- Visibility: public
QL\Dom\Elements::load()
- Visibility: public
QL\Dom\Elements::trigger()
- Visibility: public
QL\Dom\Elements::triggerHandler()
- Visibility: public
QL\Dom\Elements::bind()
- Visibility: public
QL\Dom\Elements::unbind()
- Visibility: public
QL\Dom\Elements::change()
- Visibility: public
QL\Dom\Elements::submit()
- Visibility: public
QL\Dom\Elements::click()
- Visibility: public
QL\Dom\Elements::wrapAllOld()
- Visibility: public
QL\Dom\Elements::wrapAll()
- Visibility: public
QL\Dom\Elements::wrapAllPHP()
- Visibility: public
QL\Dom\Elements::wrap()
- Visibility: public
QL\Dom\Elements::wrapPHP()
- Visibility: public
QL\Dom\Elements::wrapInner()
- Visibility: public
QL\Dom\Elements::wrapInnerPHP()
- Visibility: public
QL\Dom\Elements::contents()
- Visibility: public
QL\Dom\Elements::contentsUnwrap()
- Visibility: public
QL\Dom\Elements::switchWith()
- Visibility: public
QL\Dom\Elements::eq()
- Visibility: public
QL\Dom\Elements::size()
- Visibility: public
QL\Dom\Elements::length()
- Visibility: public
QL\Dom\Elements::count()
- Visibility: public
QL\Dom\Elements::end()
- Visibility: public
QL\Dom\Elements::_clone()
- Visibility: public
QL\Dom\Elements::replaceWithPHP()
- Visibility: public
QL\Dom\Elements::replaceWith()
- Visibility: public
QL\Dom\Elements::replaceAll()
- Visibility: public
QL\Dom\Elements::remove()
- Visibility: public
QL\Dom\Elements::markup()
- Visibility: public
QL\Dom\Elements::markupOuter()
- Visibility: public
QL\Dom\Elements::html()
- Visibility: public
QL\Dom\Elements::xml()
- Visibility: public
QL\Dom\Elements::htmlOuter()
- Visibility: public
QL\Dom\Elements::xmlOuter()
- Visibility: public
QL\Dom\Elements::php()
- Visibility: public
QL\Dom\Elements::markupPHP()
- Visibility: public
QL\Dom\Elements::markupOuterPHP()
- Visibility: public
QL\Dom\Elements::children()
- Visibility: public
//Get all the img child nodes under the class for two elements
$data = $ql->find('.two')->children('img')->attrs('alt');
print_r($data->all());
//Get the class for all child nodes under the two elements
$data = $ql->find('.two')->children()->map(function ($item){
//Use is to determine the node type
if($item->is('a')){
return $item->text();
}elseif($item->is('img'))
{
return $item->alt;
}
});
print_r($data->all());
QL\Dom\Elements::ancestors()
- Visibility: public
QL\Dom\Elements::append()
- Visibility: public
QL\Dom\Elements::appendPHP()
- Visibility: public
QL\Dom\Elements::appendTo()
- Visibility: public
QL\Dom\Elements::prepend()
- Visibility: public
QL\Dom\Elements::prependPHP()
- Visibility: public
QL\Dom\Elements::prependTo()
- Visibility: public
QL\Dom\Elements::before()
- Visibility: public
QL\Dom\Elements::beforePHP()
- Visibility: public
QL\Dom\Elements::insertBefore()
- Visibility: public
QL\Dom\Elements::after()
- Visibility: public
QL\Dom\Elements::afterPHP()
- Visibility: public
QL\Dom\Elements::insertAfter()
- Visibility: public
QL\Dom\Elements::insert()
- Visibility: public
QL\Dom\Elements::index()
- Visibility: public
QL\Dom\Elements::slice()
- Visibility: public
QL\Dom\Elements::reverse()
- Visibility: public
QL\Dom\Elements::text()
- Visibility: public
QL\Dom\Elements::plugin()
- Visibility: public
QL\Dom\Elements::extend()
- Visibility: public
QL\Dom\Elements::_next()
- Visibility: public
QL\Dom\Elements::_prev()
- Visibility: public
QL\Dom\Elements::prev()
- Visibility: public
QL\Dom\Elements::prevAll()
- Visibility: public
QL\Dom\Elements::nextAll()
- Visibility: public
QL\Dom\Elements::siblings()
- Visibility: public
QL\Dom\Elements::not()
- Visibility: public
QL\Dom\Elements::add()
- Visibility: public
QL\Dom\Elements::parent()
- Visibility: public
QL\Dom\Elements::parents()
- Visibility: public
QL\Dom\Elements::stack()
- Visibility: public
QL\Dom\Elements::attr()
- Visibility: public
QL\Dom\Elements::attrPHP()
- Visibility: public
QL\Dom\Elements::removeAttr()
- Visibility: public
QL\Dom\Elements::val()
- Visibility: public
QL\Dom\Elements::andSelf()
- Visibility: public
QL\Dom\Elements::addClass()
- Visibility: public
QL\Dom\Elements::addClassPHP()
- Visibility: public
QL\Dom\Elements::hasClass()
- Visibility: public
QL\Dom\Elements::removeClass()
- Visibility: public
QL\Dom\Elements::toggleClass()
- Visibility: public
QL\Dom\Elements::_empty()
- Visibility: public
QL\Dom\Elements::each()
- Visibility: public
QL\Dom\Elements::callback()
- Visibility: public
QL\Dom\Elements::data()
- Visibility: public
QL\Dom\Elements::removeData()
- Visibility: public
QL\Dom\Elements::rewind()
- Visibility: public
QL\Dom\Elements::current()
- Visibility: public
QL\Dom\Elements::key()
- Visibility: public
QL\Dom\Elements::next()
- Visibility: public
QL\Dom\Elements::valid()
- Visibility: public
QL\Dom\Elements::offsetExists()
- Visibility: public
QL\Dom\Elements::offsetGet()
- Visibility: public
QL\Dom\Elements::offsetSet()
- Visibility: public
QL\Dom\Elements::offsetUnset()
- Visibility: public
QL\Dom\Elements::whois()
- Visibility: public
QL\Dom\Elements::dump()
- Visibility: public
QL\Dom\Elements::dumpWhois()
- Visibility: public
QL\Dom\Elements::dumpLength()
- Visibility: public
QL\Dom\Elements::dumpTree()
- Visibility: public
QL\Dom\Elements::dumpDie()
- Visibility: public