Else branch processor
Core v2.2.0
The
processor executes when the preceding
condition
evaluates to false. Used with
for conditional branching logic.
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<if condition="${stock > 0}">
<def var="status" value="In Stock"/>
</if>
<else>
<def var="status" value="Out of Stock"/>
</else>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="title">
<xpath expression="//h1/text()">
<html-to-xml>${response}</html-to-xml>
</xpath>
</def>
<if condition="${!empty(title)}">
<file path="title.txt" action="write">${title}</file>
</if>
<else>
<file path="errors.log" action="append">
Title not found on page ${url}
</file>
</else>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="response">
<try>
<http url="https://api.example.com/data"/>
</try>
<catch>
<empty/>
</catch>
</def>
<if condition="${!empty(response)}">
<!-- Process successful response -->
<def var="data">
<json-to-xml>${response}</json-to-xml>
</def>
</if>
<else>
<!-- Fallback to cached data -->
<def var="data">
<file path="cache/last-response.xml" action="read"/>
</def>
</else>
</config>
or
block