Dashboard > Cast Iron FAQ > Home > HOWTO - Speed up loops with Xpath filters
  Cast Iron FAQ Log In | Sign Up   View a printable version of the current page.  
  HOWTO - Speed up loops with Xpath filters

Added by Matt Wennersten , last edited by Matt Wennersten on Oct 15, 2008
Labels: 
(None)

Projects often require for records of a given status code in an array to be processed differently.  Rather than loop over every record in the array and test each one individually, it can be more efficient to only loop over useful records.  Xpath is a convenient way to filter out records prior to looping.

The attached project shows how to split the following array of records such that only records whose field1 has a value of 'S' are looped:

<?xml version="1.0" encoding="UTF-8"?>
<SimpleXML>
 <Rec>
 <field1>S</field1>
 <field2>asdf</field2>
 </Rec>
 <Rec>
 <field1>C</field1>
 <field2>asdf</field2>
 </Rec>
 <Rec>
 <field1>X</field1>
 <field2>asdf</field2>
 </Rec>
 <Rec>
 <field1>S</field1>
 <field2>asdf</field2>
 </Rec>
 <Rec>
 <field1>M</field1>
 <field2>asdf</field2>
 </Rec>
 </SimpleXML>

To test it, launch in Verify mode on Studio 3.7.x+ and simply post to the configured URL of the HTTP receive. The inputs are hard-coded in the body variable of the HTTP receive activity.

Copyright(c) CustomWare Asia Pacific Pty Ltd
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators