XML structures:#!/usr/bin/perl use XML::Simple; use Data::Dumper; my $file = $ARGV[0]; $xml = new XML::Simple; my $data = $xml->XMLin($file, ForceArray=>['xs:element']); open FH,">file.out"; print FH Dumper($data); foreach my $complex(keys %{$data->{'xs:complexType'}}) { my $seq = $data->{'xs:complexType'}->{$complex}->{'xs:sequence'}; my $elementref; if (exists($seq->{'xs:element'}->{'xs:choice'})){ $elementref = $seq->{'xs:element'}->{'xs:choice'};} elsif (exists($seq->{'xs:choice'}->{'xs:element'})){ $elementref = $seq->{'xs:choice'}->{'xs:element'};} if (exists($seq->{'xs:element'})){ $elementref = $seq->{'xs:element'}; } elsif (exists($seq->{'xs:choice'})){ $elementref = $seq->{'xs:choice'};} else { die "unknown data structure at $complex->xs:sequence\n";} foreach my $element (keys %$elementref){ print "$complex.$element\n"; } }
for this I want something like this AlternateSecurityIdentification1.Id.DmstIdSrc AlternateSecurityIdentification1.Id.PrtryIdSrc Not sure how to write the structure<xs:complexType name="AlternateSecurityIdentification1"> <xs:sequence> <xs:element name="Id" type="Max35Text"/> <xs:choice> <xs:element name="DmstIdSrc" type="CountryCode"/> <xs:element name="PrtryIdSrc" type="Max35Text"/> </xs:choice> </xs:sequence> </xs:complexType>
ActiveOrHistoricCurrencyAnd13DecimalAmount.Ccy Not sure how to write the structure<xs:complexType name="ActiveOrHistoricCurrencyAnd13DecimalAmount"> <xs:simpleContent> <xs:extension base="ActiveOrHistoricCurrencyAnd13DecimalAmount_SimpleT +ype"> <xs:attribute name="Ccy" type="ActiveOrHistoricCurrencyCode" use="requ +ired"/> </xs:extension> </xs:simpleContent> </xs:complexType>
In reply to Perl parsing XML using XML::Simple by thickice97
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |