Hello, I need to get few values from a XML file and output needs to be written in another file with pipe delimited format. The Header & Footer of the Pipe Delimited file will be constant.
The below is my sample XML file. I need to pull the values in between the XML tags <Operator_info to </Operator_info>. The values are NAME, PROFILE, ENABLE STATUS (IF status is Enabled leave Blank and DISABLED write first character D) and LASTSIGNON Date.
XML INPUT FILE:
<?xml version="1.0" encoding="UTF-8"?>
<OpList xmlns="urn:swift:saa:xsd:extractor">
<Operator_info xmlns="urn:swift:saa:xsd:extractor">
<!-- *** Extracted Data for Operators *** -->
<ns5:OperatorDefn xmlns="urn:swift:saa:xsd:operator" xmlns:ns2="urn:swift:saa:xsd:authenticationservergroup" xmlns:ns3="urn:swift:saa:xsd:operatorprofile" xmlns:ns4="urn:swift:saa:xsd:unit" xmlns:ns5="urn:swift:saa:xsd:extractor" xmlns:ns6="urn:swift:saa:xsd:licenseddestination">
<ns5:Operator>
<Identifier>
<Name>HELLO123</Name>
</Identifier>
<Description>Virat, Kholi</Description>
<OperatorType>HUMAN</OperatorType>
<AuthenticationType>LOCAL</AuthenticationType>
<Profile>
<ns3:Name>PROFILE1</ns3:Name>
</Profile>
<Unit>
<ns4:Name>None</ns4:Name>
</Unit>
</ns5:Operator>
<ns5:EnableStatus>ENABLED</ns5:EnableStatus>
<ns5:ReEnableDate>n/a</ns5:ReEnableDate>
<ns5:ApprovalStatus>APPROVED</ns5:ApprovalStatus>
<ns5:LastChanged>25/07/14 20:15:35</ns5:LastChanged>
<ns5:LastSignOn>18/10/15</ns5:LastSignOn>
<ns5:LastEnabled>18/01/12 15:27:13</ns5:LastEnabled>
</ns5:OperatorDefn>
<ns5:OperatorDefn xmlns="urn:swift:saa:xsd:operator" xmlns:ns2="urn:swift:saa:xsd:authenticationservergroup" xmlns:ns3="urn:swift:saa:xsd:operatorprofile" xmlns:ns4="urn:swift:saa:xsd:unit" xmlns:ns5="urn:swift:saa:xsd:extractor" xmlns:ns6="urn:swift:saa:xsd:licenseddestination">
<ns5:Operator>
<Identifier>
<Name>HELLO12</Name>
</Identifier>
<Description>SACHIN,TEN</Description>
<OperatorType>HUMAN</OperatorType>
<AuthenticationType>LOCAL</AuthenticationType>
<Profile>
<ns3:Name>PROFILE2</ns3:Name>
</Profile>
<Profile>
<ns3:Name>PROFILE3</ns3:Name>
</Profile>
<Unit>
<ns4:Name>None</ns4:Name>
</Unit>
</ns5:Operator>
<ns5:EnableStatus>DISABLED</ns5:EnableStatus>
<ns5:ReEnableDate>n/a</ns5:ReEnableDate>
<ns5:ApprovalStatus>APPROVED</ns5:ApprovalStatus>
<ns5:LastChanged>14/02/12 17:34:35</ns5:LastChanged>
<ns5:LastSignOn>n/a</ns5:LastSignOn>
<ns5:LastEnabled>18/01/12 15:26:55</ns5:LastEnabled>
</ns5:OperatorDefn>
</Operator_info>
Expected Output:
20151027 GLOBAL USER GROUP --> Header Record Constant
ACR|HELLO123|PROFILE1| |20151018|HELLO123
ACR|HELLO12|PROFILE2| D||HELLO12
ACR|HELLO12|PROFILE3|D||HELLO12
NUMBER OF DETAIL RECORDS:3 --> Footer Constant and should give thetotal record number
ACR is a constant value and should follow in each record first line.