Parsing function examples
Practical examples of Custom Parser functions for HTML processing, string manipulation, mathematical operations, and common parsing tasks.
HTML processing
element_text
element_textSample HTML
<!DOCTYPE html>
<html>
<body>
<div id="product">
<div id="product-description">This is a nice product</div>
<div id="product-price"> 12 3
</div>
</div>
</body>
</html>Extract text from HTML element and strip whitespaces
{
"price": {
"_fns": [
{
"_fn": "xpath_one",
"_args": [".//*[@id='product-price']"]
},
{
"_fn": "element_text"
}
]
}
}Given a string value as an input, do nothing
xpath
xpathSample HTML
Get all description items
Get the first description item
Check if the description section element exists
Get price as a number
Multiple expressions to fallback to in case preceding expression fails
XPath | operator to match with multiple expressions
xpath_one
xpath_oneSample HTML
Return the first match
Using XSLT functions
String manipulation
amount_from_string
amount_from_stringSample HTML
Extract amount from string
amount_range_from_string
amount_range_from_stringSample HTML
Extract all amounts from string
join
joinSample HTML
Join an array of strings into a single string
regex_find_all
regex_find_allSample HTML
Find all matches between two characters
regex_search
regex_searchSample HTML
Return description between two characters
regex_substring
regex_substringSample HTML
Replace a part of text with specified value
Common functions
convert_to_*
convert_to_*Sample HTML
Get the count of price variants
Get the count of price variants in a multi-dimensional array
Sample HTML:
select_nth
select_nthSample HTML
Select the first description item from the array
Select the last description item from the array
Math functions
average
averageSample HTML
Find the average of all listed prices
max
maxSample HTML
Find the max of all listed prices
min
minSample HTML
Find the average of all listed prices
product
productSample HTML
Get the count of different product variants
Last updated
Was this helpful?

