xmlDOMSearch
Version 22.0.8473
xmlDOMSearch
Version 22.0.8473
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.
Example
Consider the XML data below, which is passed as input data to a Script Connector in CData Arc:
<Items>
<Cars>
<Subaru>
<Color>Blue</Color>
<Year>2017</Year>
</Subaru>
<Honda>
<Color>Red</Color>
</Honda>
</Cars>
</Items>
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:if>
</arc:call>
<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.