select

select ( string cssSelector , string _code , string _selection ) : string

Select someting in code using a css selector, by default on all the source code but you can indicate a portion of code, the selection correspond to what you want it return.

In this function the actions are executed in this order:
1) _code is parsed
2) cssSelector is searched in the parsed DOM
3) Once the DOM element is located, we search the property defined in _selection




Example

HTML:

<ul id="listofLanguages"> 
<li>Java </li> 
<li>Python </li> 
<li>Groovy </li>
<li>C++ </li> 
</ul>

Grimport:

firstLanguage = select("#listofLanguages li") 
console(firstLanguage) // -> "Java"

allLanguages = select("#listofLanguages", null, "text") 
console(allLanguages) 
/* -> "Java
Python
Groovy
C++"*/


See also

selectAll
cleanSelect
cleanSelectAll

Parameters

cssSelector

Use Inspect element in your browser to find the CSS selector. CSS Selector reference.
It is working for XML also.

_code (optional)

The HTML or XML code where the cssSelector should be searched. If null it is the page code in a FORPAGE script.

_selection (optional)

What do you want to extract the element from the HTML DOM?
• innerHTML or html (by default) = HTML inner the element
• outerHTML = HTML outer the element
• text = text in the element
• object = return the Elements Jsoup object
• other value = the name of the attribute in the tag
Note attribute can be "abs:href" for absolute links in a href attribute