parse xml in shell script
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.
精彩评论