For Each Tag Path

The For Each Tag Path action loops through all tags of a given type in the subtree of the found tag. In each iteration, the appropriate tag is marked as a named tag.

The For Each Tag Path action is very similar to the For Each Tag action. The main difference is that the For Each Tag action only finds the immediate children of the found tag whereas the For Each Tag Path action searches the entire subtree

See the Basic Introduction to Looping tutorial for more information.

Properties

The For Each Tag Path action can be configured using the following properties:

Tag Path

Specify the tag path which is to be looped through. The tag path is specified as in a Tag Finder. All of the matching tags in the entire subtree will be found.

Classes to Include

Specify the classes of tags to include in the result. Conjunction (logical AND) is denoted by space and disjunction (logical or) is denoted by |. Conjunction takes precedence over disjunction, for example class1 class2 specifies the tags that are both of class1 and class2, class1 | class2 | class3 specifies the tags that are either of class1, class2, or class3, whereas class1 class2 | class3 class4 specifies the tags that are either both of class1 and class2 or both of class 3 and class4.

Classes to Exclude

Specify the classes of tags to exclude from the result. Conjunction (logical AND) is denoted by space, disjunction (logical or) is denoted by |, and the explicit absence of classes is denoted by $. Conjunction takes precedence over disjunction, for example class1 class2 specifies the tags that are both of class1 and class2, class1 | $ specifies the tags that are either of class1 or of no class at all, class1 | class2 | class3 specifies the tags that are either of class1, class2, or class3, whereas class1 class2 | class3 class4 specifies the tags that are either both of class1 and class2 or both of class 3 and class4.

First Tag Number

The number of the first matching tag to include in the loop. The number can be specified to count either forward from the first tag, or backward from the last tag.

Last Tag Number

The number of the last matching tag to include in the loop. The number can be specified to count either forward from the first tag, or backward from the last tag.

Tag Number Increment

Make the loop skip tags. For example, an increment of 2 is specified, the loop will skip every second tag.

Loop Backwards

Select that the loop should loop through the matching tags in reverse order. Please note that the loop will go through exactly the same tags as if it were looping forward just in reversed order. This means that the First Tag Number is referring to first tag in the selection of tags to loop over and not the first tag visited when looping (actually it will be the last).

Tag Name

Has two options, Auto or Named.Auto gives the tag a name which is number. The first Auto-numbered tag will have number 1, the next number 2 etc. Note that the number may change if additional Auto-numbered tags are inserted before this step (on the same page).Named gives the tag a fixed and explicitly stated name, which has several advantages:

  • It is easier to remember what the named tag identifies if it has a well-chosen name
  • An explicitly named tag is not affected if another named tag is inserted before it
  • If you use the same name again in Set Named Tag, the name will simply be made to refer to the new tag (useful for stateful in-page looping)
Keep Existing Named Tags

If this option is selected, existing named tags are kept along with the named tag marking the result of each iteration. If this option is not selected, existing named tags are removed, and each output state will only contain the named tag marking the result of the iteration.

Example

Consider this found tag:

<table>
  <tbody>
    <tr>
      <td> 1 </td>
      <td> 2 </td>
    </tr>
  </tbody>
</table>
Set the Tag Path to td. The first iteration will set a named tag to <td> 1 </td> and in the next iteration, the named tag will be <td> 2 </td>

Now consider this found tag:

<table>
  <tbody>
    <tr>
      <td>
        <table>
          <tbody>
            <tr>
              <td> 1 </td>
              <td> 2 </td>
            </tr>
          </tbody>
        </table>
      </td>
      <td> 3 </td>
    </tr>
  </tbody>
</table>

Set the Tag Path to tr.td. The first iteration will set a named tag to

<td><table><tbody><tr><td> 1
</td><td> 2
</td></tr></tbody></table></td>

and in the next iteration, the named tag will be

<td> 3 </td>