开发者

How to extract a part of xml code from an xml file using Perl Script

开发者 https://www.devze.com 2023-02-13 02:55 出处:网络
\" <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?> <eRecon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"xmlns:noNamespaceSchemaLocation=\"eRecon.xsd\">
 " <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
  <eRecon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:noNamespaceSchemaLocation="eRecon.xsd">
  <Header>
  <Company Code="" /> 
  <CommonCarrierCode /> 
  <InputFileName InputIDPk="">F:\ReconNew\TmesysRec20100111.rec</InputFileName> 
  <BatchNumber>000152</BatchNumber> 
  <InputStartDateTime>2010-02-26 11:47:00</InputStartDateTime> 
  <InputFinishDateTime>2010-02-26 11:47:05</InputFinishDateTime> 
  <RecordCount>8</RecordCount> 
  </Header>
 <Detail>
  <CarrierStatusDate>2010-01-11</CarrierStatusDate> 
  <ClaimNum>YDF02892 C</ClaimNum> 
  <InvoiceNum>0108013775</InvoiceNum> 
  <LineItemNum>001</LineItemNum> 
  <NABP>10600211</NABP> 
  <RxNumber>4695045</RxNumber> 
  <RxDate>2008-07-21</RxDate> 
  <CheckNum /> 
  <PaymentStatus>PENDING</PaymentStatus> 
  <RejectDescription /> 
  <InvoiceChargeAmount>152.15</InvoiceChargeAmount> 
  <InvoicePaidAmount>131.00</InvoicePaidAmount> 
 </Detail>
 </eRecon> "

How can I extract the portion and create a new XML file

 <Header>
  <Company Code="" /> 
  <CommonCarrierCode /> 
  <InputFileName InputIDPk=""开发者_如何学运维>F:\ReconNew\TmesysRec20100111.rec</InputFileName> 
  <BatchNumber>000152</BatchNumber> 
  <InputStartDateTime>2010-02-26 11:47:00</InputStartDateTime> 
  <InputFinishDateTime>2010-02-26 11:47:05</InputFinishDateTime> 
  <RecordCount>8</RecordCount> 
 </Header>

from the above xml file.

I need the Perl Script to extract a part of xml tag from an xml file.

Thanks in Advance


If yoy are ok with awk:

awk '/Header/{pp=1} /Detail/ {pp=0} pp' filename
0

精彩评论

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