Variable setter processor
Core v2.2.0
The
processor updates the value of an existing variable in the
execution context. This is a legacy processor maintained for backward compatibility.
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="counter" value="0"/>
<loop maxloops="10">
<!-- Legacy: set-var -->
<set-var name="counter">${counter + 1}</set-var>
<!-- Modern: use def instead -->
<def var="counter" value="${counter}1"/>
</loop>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="count" value="5"/>
<!-- set-var has basic arithmetic -->
<set-var name="count">${count + 1}</set-var>
<set-var name="count">${count - 1}</set-var>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="totalItems" value="0"/>
<loop item="page" maxloops="5">
<def var="pageItems">
<xpath expression="count(//item)">
<http url="https://api.example.com/page/${page}"/>
</xpath>
</def>
<!-- Add to total (string concatenation, not arithmetic!) -->
<set-var name="totalItems">${totalItems}${pageItems}</set-var>
</loop>
</config>
for new configurationsname="x"
instead of var="x"
${x + 1
} is string concat, not math (use script for real math)