在shell脚本中解析xml

时间:2011-03-18 09:25:56

标签: xml shell unix scripting

在我的xml中我有一个特定的字段,如下所示我想获取select查询并在我的脚本中再次使用它。有时查询很长并且也有新行。它嵌入到xml中。

下面是我要提取的xml的一部分,它不是完整的xml。我想读取xml,然后从文本中取出部分开头,然后从中提取查询。

或者让我说要在text =“ until ”>之间提取部分。

text="select * from dual">
text="select * from xml_config">
text="select * from
       WHERE SOC_STATUS='A') sa,
       SUBSCRR sub,
       UH_TEMP_CUSTO leading
       where   (NVL(SA.EXRATION_DATE,SYSDATE) >= SYSDATE - ${HISTORY_DAYS})
       AND sub.CUSTOMER_ID=LEADING.CUSTOMER_ID
       AND sa.AGREEMENT_NO = sub.SUBSCRIBER_NO
       AND SUB.EFFECTIVE_DATE!=NVL(SUB.EXRATION_DATE,SUB.EFFECTIVE_DATE+1) 
       ORDER BY sa.AGREEMENT_NO">

output:

    value[0] =select * from dual
    value[1]=select * from xml_config
    value[2]=select * from WHERE SOC_STATUS='A') sa,SUBSCRR sub,
             UH_TEMP_CUSTO leading where   (NVL(SA.EXRATION_DATE,SYSDATE) >= SYSDATE - ${HISTORY_DAYS}) AND .CUSTOMER_ID=LEADING.CUSTOMER_ID
    AND sa.AGREEMENT_NO = sub.SUBSCRIBER_NO AND SUB.EFFECTIVE_DATE!=NVL(SUB.EXRATION_DATE,SUB.EFFECTIVE_DATE+1) 
    ORDER BY sa.AGREEMENT_NO

-Thanks

1 个答案:

答案 0 :(得分:0)

我无法阅读您的问题,但答案是XMLStarlet