Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ibm mq 提取循环中的xml值_Ibm Mq_Messagebroker - Fatal编程技术网

Ibm mq 提取循环中的xml值

Ibm mq 提取循环中的xml值,ibm-mq,messagebroker,Ibm Mq,Messagebroker,我有一个类似xml的 <NS5:CAIAssembly> <NS5:CAIComponent > <NS5:CAICode>033144</NS5:CAICode> <NS5:Quantity>1</NS5:Quantity> </NS5:CAIComponent> <NS5:CAICom

我有一个类似xml的

 <NS5:CAIAssembly> 
          <NS5:CAIComponent > 
            <NS5:CAICode>033144</NS5:CAICode> 
            <NS5:Quantity>1</NS5:Quantity> 
          </NS5:CAIComponent> 
          <NS5:CAIComponent > 
            <NS5:CAICode>048429</NS5:CAICode> 
            <NS5:Quantity>1</NS5:Quantity> 
          </NS5:CAIComponent> 
          <NS5:CAIComponent > 
            <NS5:CAICode>073528</NS5:CAICode> 
            <NS5:Quantity>1</NS5:Quantity> 
          </NS5:CAIComponent> 
          <NS5:CAIComponent > 
            <NS5:CAICode>563781</NS5:CAICode> 
            <NS5:Quantity>1</NS5:Quantity> 
          </NS5:CAIComponent> 
        </NS5:CAIAssembly>
上面的代码只给出了一个类似的结果

<components> 
<productCd >033144_5423</productCd > 
<quantity>1</quantity> 
</components

033144_5423 
1.

我如何迭代这些值以获得类似的结果

我尝试了While循环,但它不起作用

<components> 
<productCd >033144_5423</productCd > 
<quantity>1</quantity> 
</components> 
<components> 
<productCd >048429_5423</productCd > 
<quantity>1</quantity> 
</components> 
<components> 
<productCd >073528_5423</productCd > 
<quantity>1</quantity> 
</components> 
<components> 
<productCd >563781_5423</productCd > 
<quantity>1</quantity> 
</components>

033144_5423 
1.
048429_5423 
1.
073528_5423 
1.
563781_5423 
1.

谢谢大家。

这很容易实现。请尝试以下代码:

 DECLARE inputRef REFERENCE TO InputRoot.XMLNSC.NS5:CAIAssembly;

    DECLARE Ref_CAIComponent REFERENCE TO inputRef.NS5:CAIComponent[1];

    --Now run the below loop

        WHILE LASTMOVE(Ref_CAIComponent) DO

    CREATE FIELD OutputRoot.XMLNSC.components[index];
    DECLARE outRef REFERENCE TO OutputRoot.XMLNSC.components[index];
    SET index=index+1;

    SET outRef.productCd=Ref_CAIComponent.NS5:CAICode;
    SET outRef.quantity=Ref_CAIComponent.NS5:Quantity;


    MOVE Ref_CAIComponent NEXTSIBLING REPEAT NAME;
    END WHILE;

p.S.自己奋斗并找到解决方案,而不是寻找填鸭式的方法,这是一种很好的做法。

谢谢,但我已经自己解决了。:)就在同一天,我在这里遇到了一个问题,你能提供给我你有价值的投入吗
 DECLARE inputRef REFERENCE TO InputRoot.XMLNSC.NS5:CAIAssembly;

    DECLARE Ref_CAIComponent REFERENCE TO inputRef.NS5:CAIComponent[1];

    --Now run the below loop

        WHILE LASTMOVE(Ref_CAIComponent) DO

    CREATE FIELD OutputRoot.XMLNSC.components[index];
    DECLARE outRef REFERENCE TO OutputRoot.XMLNSC.components[index];
    SET index=index+1;

    SET outRef.productCd=Ref_CAIComponent.NS5:CAICode;
    SET outRef.quantity=Ref_CAIComponent.NS5:Quantity;


    MOVE Ref_CAIComponent NEXTSIBLING REPEAT NAME;
    END WHILE;