> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# xmlDOMSearch

> Loops over the elements in an input XML document using an xpath to enumerate repeating structures.

Loop over the elements in an input XML document.

## Required Parameters

* **xpath**: The 1-based index xpath of the specified segment to loop over. For example, `<arc:set attr="myinputitem.xpath" value="/Items/foo/" />`.

## Optional Parameters

* **uri**: An XML file URI. For example, `http://mydomain.com/resources/somedata.xml`, `/tmp/myfile.xml`, or `[FilePath]`.
* **text**: A readable handle reference to the XML data. This handle is created by the [xmlOpen](./op-xml-open) operation and is helpful when the input XML is not a file or raw text, or when it is necessary to perform multiple actions that access the file data of the document.
* **handle**: A readable handle reference to the XML data. This handle is created by the xmlOpen operation and is only necessary when the target XML is not an input file. See [xmlOpen](./op-xml-open) for details and examples.

## Output Attributes

* **xpath**: Returns the full 1-based index xpath of the specified element being looped over. For example, `[myoutitem.xpath]` resolves to the xpath of the `foo` XML element, which is `/Items/foo[1]`.
* **xname**: Returns the name of the element being looped over. For example, `[myoutitem.xname]` resolves to the name of the `foo` XML element, which is `foo`.

## Example

Consider the following XML, which is passed in as an input file:

```xml theme={null}
<Items>
    <hello>world</hello>
    <colors>
        <color>yellow</color>
        <example>banana</example>
    </colors>
    <colors>
        <color>red</color>
        <example>apple</example>
    </colors>
    <colors>
        <color>orange</color>
        <example>orange</example>
    </colors>
</Items>
```

You can use the xmlDOMSearch operation to enumerate over all the child elements in each `<colors>` parent element, as shown below:

```xml theme={null}
<!-- Setting the input uri and xpath -->
<arc:set attr="xml.uri" value="[FilePath]" />
<arc:set attr="xml.xpath" value="/Items/colors" />

<!-- Calling the operation, passing in the xml item --> 
<arc:call op="xmlDOMSearch" in="xml" >
  <!-- Inside the call you can reference elements at paths relative to the input "xpath" -->
  <!-- In this example each color and example is written to the output data -->
  <arc:set attr="_log.info" value="Color = [xpath(color)]" />
  <arc:set attr="_log.info" value="Example = [xpath(example)]" />
</arc:call>

<!-- Setting the output file and pushing the file out -->
<arc:set attr="output.filepath" value="[FilePath]" />
<arc:push item="output" />
```

The output in the application log looks like this:

<img src="https://mintlify.s3.us-west-1.amazonaws.com/cdata-arc/26.2/cloud/en/scripting/operations/assets/images/jsonDOMSearch.png" width="600" />
