A
anthony
Hi, I have an XML file that I am reading and I am using XML::Simple to
do it.
Within the XML file there are certain root elements that contain
multiples of the same element name with different values.
I want to be able to collect these different values but have a
different delimiter other than the comma.
My example XML element is:
<record id="2823" action="add">
<id>MSS-020-01</id>
<vendorid>112233-12</vendorid>
<date>2004-04-23</date>
<severity>L</severity>
<arch>sparc</arch>
<os>SunOS</os>
<osver>9</osver>
<obsoletes>112961-01</obsoletes>
<obsoletes>113024-07</obsoletes>
<obsoletes>113030-02</obsoletes>
<obsoletes>113223-02</obsoletes>
<obsoletes>113275-02</obsoletes>
<obsoletes>113361-08</obsoletes>
<obsoletes>113454-14</obsoletes>
<obsoletes>113538-11</obsoletes>
<obsoletes>113577-01</obsoletes>
<obsoletes>114359-02</obsoletes>
<obsoletes>114385-03</obsoletes>
<obsoletes>114393-02</obsoletes>
<obsoletes>114394-02</obsoletes>
<obsoletes>115169-01</obsoletes>
<desc>Sun Security Vulnerability With the Extended Library Function
sendfilev(3EXT)</desc>
</record>
My code that reads this file :
my $struct = $simple->XMLin($xmlcontent, forcearray => 1, keeproot =>
1, noattr => 1, SuppressEmpty => 1, GroupTags => { osver => 'obsoletes'
} );
print FILE <<EOF;
$_->{ibmid}->[0],$_->{vendorid}->[0],$num,$_->{severity}->[0],$_->{arch}->[0],$_->{os}->[0],$_->{osver}->[0],$_->{obsoletes}->[0],$_->{obsoletes}->[1]
You will notice that I am reading the first 2 obsolete element names -
but I think there is a better way to read them.
What I would like the file to look like is this:
MSS-020-01,112233-12,,L,sparc,SunOS,9,112961-01:113024-07:113030-02:113223-02:113275-02
etc. with no comma separating the obsolete values.
At the moment, the code above will produce:
MSS-020-01,112233-12,,L,sparc,SunOS,9,112961-01,113024-07 (2 obsolete
entries because I read first and second values only)
do it.
Within the XML file there are certain root elements that contain
multiples of the same element name with different values.
I want to be able to collect these different values but have a
different delimiter other than the comma.
My example XML element is:
<record id="2823" action="add">
<id>MSS-020-01</id>
<vendorid>112233-12</vendorid>
<date>2004-04-23</date>
<severity>L</severity>
<arch>sparc</arch>
<os>SunOS</os>
<osver>9</osver>
<obsoletes>112961-01</obsoletes>
<obsoletes>113024-07</obsoletes>
<obsoletes>113030-02</obsoletes>
<obsoletes>113223-02</obsoletes>
<obsoletes>113275-02</obsoletes>
<obsoletes>113361-08</obsoletes>
<obsoletes>113454-14</obsoletes>
<obsoletes>113538-11</obsoletes>
<obsoletes>113577-01</obsoletes>
<obsoletes>114359-02</obsoletes>
<obsoletes>114385-03</obsoletes>
<obsoletes>114393-02</obsoletes>
<obsoletes>114394-02</obsoletes>
<obsoletes>115169-01</obsoletes>
<desc>Sun Security Vulnerability With the Extended Library Function
sendfilev(3EXT)</desc>
</record>
My code that reads this file :
my $struct = $simple->XMLin($xmlcontent, forcearray => 1, keeproot =>
1, noattr => 1, SuppressEmpty => 1, GroupTags => { osver => 'obsoletes'
} );
print FILE <<EOF;
$_->{ibmid}->[0],$_->{vendorid}->[0],$num,$_->{severity}->[0],$_->{arch}->[0],$_->{os}->[0],$_->{osver}->[0],$_->{obsoletes}->[0],$_->{obsoletes}->[1]
You will notice that I am reading the first 2 obsolete element names -
but I think there is a better way to read them.
What I would like the file to look like is this:
MSS-020-01,112233-12,,L,sparc,SunOS,9,112961-01:113024-07:113030-02:113223-02:113275-02
etc. with no comma separating the obsolete values.
At the moment, the code above will produce:
MSS-020-01,112233-12,,L,sparc,SunOS,9,112961-01,113024-07 (2 obsolete
entries because I read first and second values only)