Esql 如何使用 select 语句从输入 xml 中检索值

Esql how to use select statement to retrieve value from input xml

我有一个输入 xml 看起来像这样

<log>
    <line>
        <id>1</id>
    <line>
        <id>2</id>
    <otherLine>
        <id>2</id>
        <field>
            12345-67
        </field>
    </otherLine>
</log>

我在 esql 中所做的基本上是遍历每个 <line> 元素,我想从 <id> 值匹配的 <otherLine> 检索值。

我有这样的代码:

declare inDoc reference to InputRoot.XMLNSC.log;
declare line reference to inDoc;
declare fieldValue character;

move line firstchild name 'line';
while lastmove(line) do

    set fieldValue = select r.field from inDoc.otherLine[] as r where r.id = line.id;
    -- I want this to be null when hitting the line with <id>1</id> and 12345-67 and hitting the line with <id>2</id>

    move line nextsibling name 'line';
end while

我尝试部署代码时出现以下错误:

BIP2497E: (MyApp_flow.Main, <line number of select statement>) : Illegal data type for target. A list field reference is required. 

The expression supplying the target must evaluate to a value of a suitable type. The given expression cannot possibly do so. 

Correct the syntax of your ESQL expression in node 'MyApp_flow.Main', around line and column '<line number of the select statement>', then redeploy the message flow.

我想知道在 esql 中完成此任务的正确方法是什么

谢谢

解决方案是在 select 语句中使用 theitemfieldvalue

set fieldValue = the(select item fieldvalue(r.field) from inDoc.otherLine[] as r where r.id = line.id);