开发者

parse xml in shell script

开发者 https://www.devze.com 2023-02-18 03:02 出处:网络
In my xml I have a particular field like below I want to get the select query and use it in my script again.Sometime the query is very long and have new line also. This is embedded into an xml.

In my xml I have a particular field like below I want to get the select query and use it in my script again.Sometime the query is very long and have new line also. This is embedded into an xml .

Below are the part of the xml I want to extract , it is not 开发者_如何学Pythonthe complete xml.I want to read the xml and then take out the part start with text and from that extract the query.

Or lets say I want to extract the part between the text=" till "> .

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


I can't read your question, but the answer is XMLStarlet.

0

精彩评论

暂无评论...
验证码 换一张
取 消