Version 23.3.8698


Version 23.3.8698

Loop from an XML document.

Required Parameters

  • xpath: The XPath of the specified segment.

Optional Parameters

  • uri: An XML file URI.
  • handle: The handle of the specified XML reader.

Output Attributes

  • xpath: The XPaths that match the specified input.
  • xname: The name of the matched element.


Consider the XML data below, which is passed as input data to a Script Connector in CData Arc:


In this Script Connector, you can invoke xmlDOMSearch in ArcScript to search this XML data for cars with the color Blue and add the Year of the corresponding cars as headers to a message in Arc. The ArcScript code below shows an example of how to do this:

<arc:set attr="xml.xpath" value="/Items/Cars/Subaru" />
<arc:set attr="xml.uri" value="[Filepath]" />
<arc:call op="xmlDOMSearch" in="xml" out="result">
  <!-- xpath is a context senstive function in arcscript. If an xml document is loaded in a 
       search, xpath will return the name of a child relative to the search result -->
  <arc:if exp="[xpath('Color') | equals('Blue')]">
    <arc:set attr="output.header:caryear" value="[xpath('Year')]" />

<arc:set attr="output.filename" value="[Filename]" />
<arc:push item="output" />

After this code executes, Arc pushes the file with the newly added headers as output down the flow.