基本上我需要处理XML文件响应,该响应在单个文件中包含多个块作为输出。所以我需要在unix中将各个块转换为单独的行。
来源数据:
<xml.ValidateAddressResponse xmlns="http://www.pb.com/spectrum/services/ValidateAddress">
<output_port>
<Address>
<Confidence>82</Confidence>
<RecordType>Normal</RecordType>
<CountryLevel>A</CountryLevel>
<ProcessedBy>USA</ProcessedBy>
<MatchScore>0</MatchScore>
<AddressLine1>1825 Kramer Ln</AddressLine1>
<City>Austin</City>
<StateProvince>TX</StateProvince>
<PostalCode>78758-4260</PostalCode>
<PostalCode.Base>78758</PostalCode.Base>
<PostalCode.AddOn>4260</PostalCode.AddOn>
<Country>United States Of America</Country>
<user_fields/>
</Address>
</output_port>
</xml.ValidateAddressResponse>
<xml.ValidateAddressResponse xmlns="http://www.pb.com/spectrum/services/ValidateAddress">
<output_port>
<Address>
<Confidence>82</Confidence>
<RecordType>Normal</RecordType>
<CountryLevel>A</CountryLevel>
<ProcessedBy>USA</ProcessedBy>
<MatchScore>0</MatchScore>
<AddressLine1>1825 Kramer Ln</AddressLine1>
<City>Austin</City>
<StateProvince>TX</StateProvince>
<PostalCode>78758-4260</PostalCode>
<PostalCode.Base>78758</PostalCode.Base>
<PostalCode.AddOn>4260</PostalCode.AddOn>
<Country>United States Of America</Country>
<user_fields/>
</Address>
</output_port>
</xml.ValidateAddressResponse>
需要输出:
<xml.ValidateAddressResponse xmlns="http://www.pb.com/spectrum/services/ValidateAddress"><output_port><Address><Confidence>82</Confidence><RecordType>Normal</RecordType><CountryLevel>A</CountryLevel><ProcessedBy>USA</ProcessedBy><MatchScore>0</MatchScore><AddressLine1>1825 Kramer Ln</AddressLine1><City>Austin</City><StateProvince>TX</StateProvince><PostalCode>78758-4260</PostalCode><PostalCode.Base>78758</PostalCode.Base><PostalCode.AddOn>4260</PostalCode.AddOn><Country>United States Of America</Country><user_fields/></Address></output_port></xml.ValidateAddressResponse>
<xml.ValidateAddressResponse xmlns="http://www.pb.com/spectrum/services/ValidateAddress"><output_port><Address><Confidence>82</Confidence><RecordType>Normal</RecordType><CountryLevel>A</CountryLevel><ProcessedBy>USA</ProcessedBy><MatchScore>0</MatchScore><AddressLine1>1825 Kramer Ln</AddressLine1><City>Austin</City><StateProvince>TX</StateProvince><PostalCode>78758-4260</PostalCode><PostalCode.Base>78758</PostalCode.Base><PostalCode.AddOn>4260</PostalCode.AddOn><Country>United States Of America</Country><user_fields/></Address></output_port></xml.ValidateAddressResponse>
请指导我这个案子。
答案 0 :(得分:0)
(echo v/\<xml.ValidateAddressResponse/-,.j; echo w) | ed file.txt