If Node
From Moving Pictures
The if node is your way of putting a conditional into your scraper. The if node takes one attribute, and it is required.
| Attribute | Description |
|---|---|
| test | This is a required attribute for this node. It is also the only attribute. This is where you set your condition statement. |
| Condition | Description |
| >= | This tests if the left side is greater than or equal to the right side. |
| <= | This test of the left side is less than or equal to the right side. |
| != | This tests if the left side is not equal to the right side. |
| = | This tests if the left side and the right side are the same (equal). |
| < | This test if the left side is less than the right side. |
| > | This test if the left side is greater than the right side. |
<if test="${leftSide}!=${rightSide}">
<!-- code to run if test returns true -->
</if>
Examples
You could do the following if to determine if a variable has a value set to it.
<if test="${leftSide}!=">
<!-- code to run if ${leftSide} is not blank -->
</if>
You could do the following if to determine if a variable has no value set to it.
<if test="${leftSide}=">
<!-- code to run if ${leftSide} is blank -->
</if>
Note
For the characters "<" and ">" you need to use the Predefined entities in XML. The syntax is "&name;" where name is the name of the entity. Use "lt" for < and "gt" for >.