xmlDOMSearch
Version 23.4.8841
Version 23.4.8841
xmlDOMSearch
入力XML ドキュメントの要素をループします。
必要なパラメータ
- xpath:The 1-based index xpath of the specified segment to loop over. For example,
<arc:set attr="myinputitem.xpath" value="/Items/foo/" />
.
オプションのパラメータ
- 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 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 for details and examples.
アウトプット属性
- xpath:Returns the full 1-based index xpath of the specified element being looped over. For example,
[myoutitem.xpath]
resolves to the xpath of thefoo
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 thefoo
XML element, which isfoo
.
例
Consider the following XML, which is passed in as an input file:
<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:
<!-- 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: