xmlDOMSearch

Version 21.0.8222


xmlDOMSearch

Version 21.0.8222


XML ドキュメントからループ。

必要なパラメータ

  • 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 ArcESB:

<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 ArcESB. 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" />
  • 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 ArcESB:

<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 ArcESB. 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 a json 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, ArcESB pushes the file with the newly added headers as output down the flow.

オプションのパラメータ

  • uri:XML ファイルのURI。
  • handle:指定されたXML リーダーのハンドル。

Output Attributes

  • xpath:指定されたインプットに合致するXPath。