current location : My anomaly network » Other development languages  » shell Script parsing xml file , obtain body Content solution ideas

shell Script parsing xml file , obtain body Content solution ideas

www.myexceptions.net   Share with netizens :2015-02-11   browse :0 second

shell Script parsing xml file , obtain body content

Hello, ladies and gentlemen , I am right shell Script fledgling , I have a question for you , Please help Daniel to have a look :

Problem description :

Now there's a xml File data , this xml There are nodes in it DATA_NAME,DATABODY The content is the data I want , But each DATABODY It's paginated , Like every 10 The data is divided into one page PAGE, I want to put all PAGE Content of , Input to a text file , name DATA_NAME Node value .

give an example :

File names are similar :99200000000_AMRGT_CONV_0000_20130427_I_0305_0001.xml

xml The data format is as follows :

AMRGT_CONV

I

0000000013

00000002

6

INTER_ACCT

ACCOUNT

SUBACCT

PACT_TERM

DEFER_TERM

CONTRACT

1029451|+|944002010000541249|+|999|+|12|+|0|+|31312|-|

996941|+|100870912250012222|+|999|+|12|+|0|+|888888888555555|-|

1029716|+|961009010000055621|+|999|+|12|+|0|+|qwwew|-|

1030582|+|961003010000132335|+|999|+|12|+|12|+|22222|-|

1029694|+|937006010000000001|+|999|+|3|+|0|+|742947974382977|-|

1029057|+|944001010000528906|+|999|+|3|+|0|+|11111111111111111111|-|

1030198|+|944000010000580009|+|999|+|3|+|0|+|11111111111111111111|-|

950152|+|100830440700010001|+|999|+|12|+|12|+|3456789|-|

1030578|+|961000010000118816|+|999|+|12|+|0|+|123456|-|

1030611|+|961005010000132341|+|999|+|12|+|0|+|11|-|

1027383|+|144003010000412232|+|999|+|3|+|0|+|11111111111111111111|-|

8006634|+|961007010000675750|+|999|+|12|+|0|+|342343|-|

1031152|+|961004010000261315|+|999|+|6|+|6|+|56568383838385656|-|

The end result is :

Text file name :AMRGT_CONV.txt

Text content :

1029451|+|944002010000541249|+|999|+|12|+|0|+|31312|-|

996941|+|100870912250012222|+|999|+|12|+|0|+|888888888555555|-|

1029716|+|961009010000055621|+|999|+|12|+|0|+|qwwew|-|

1030582|+|961003010000132335|+|999|+|12|+|12|+|22222|-|

1029694|+|937006010000000001|+|999|+|3|+|0|+|742947974382977|-|

1029057|+|944001010000528906|+|999|+|3|+|0|+|11111111111111111111|-|

1030198|+|944000010000580009|+|999|+|3|+|0|+|11111111111111111111|-|

950152|+|100830440700010001|+|999|+|12|+|12|+|3456789|-|

1030578|+|961000010000118816|+|999|+|12|+|0|+|123456|-|

1030611|+|961005010000132341|+|999|+|12|+|0|+|11|-|

1027383|+|144003010000412232|+|999|+|3|+|0|+|11111111111111111111|-|

8006634|+|961007010000675750|+|999|+|12|+|0|+|342343|-|

1031152|+|961004010000261315|+|999|+|6|+|6|+|56568383838385656|-|

Ask Daniel ha , How to use it? shell Script to get what I want ?

Please ...

------ Solution ideas ----------------------

use shell Script parsing xml, It's all egg pain , A slight change in format and line feed is not applicable . Why not python And other languages with special libraries ?

Last : period

Article review

Technology