I am very new to XML. Really I have an excel file that I am trying to read w/
Perl on a Linux machine. I don't have a mod for reading excel files so I have to convert the excel file to xml to be able to read it. I can read the file and everything is ok except...the Number style is being dropped out for some reason...see code below. Please help.
XML snipit (the target being dropped is highlighted red):
Code:
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s23">
<Font x:Family="Swiss" ss:Size="8.0"/>
</Style>
<Style ss:ID="s24">
<NumberFormat ss:Format="Currency"/>
</Style>
<Style ss:ID="s25">
<NumberFormat ss:Format=""$"#,##0_);[Red]\("$"#,##0\)"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="256" ss:ExpandedRowCount="994" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="65.0" ss:DefaultRowHeight="12.0">
<Column ss:AutoFitWidth="0" ss:Width="102.0"/>
<Column ss:AutoFitWidth="0" ss:Width="53.0"/>
<Column ss:Width="58.0"/>
<Column ss:AutoFitWidth="0" ss:Width="53.0" ss:Span="252"/>
<Row>
<Cell ss:MergeAcross="2"><Data ss:Type="String">Old Navy - ' Future Football Star' Romper</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">ah1026</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Loved</Data></Cell>
<Cell ss:Index="3" ss:StyleID="s24"><Data ss:Type="Number">3.0</Data></Cell>
</Row>
Perl Script:
Code:
use XML::Parser;
$xp=new XML::Parser();
$xp->setHandlers(Start => \&start, End => \&end, Char => \&cdata);
$xp->parsefile("test.xml");
$ctag=0;
sub start(){
my ($p, $name, %attr) = @_;
$ctag = lc($name);
}
sub cdata(){
my ($parser, $target, $data) = @_;
if (lc($target) == "cell"){
if (($target=~/\w|\d/) && ($target ne "False") && ($target !~ /#/)){
push @array, $target;
}
}
}
sub end(){
my ($p, $name) = @_;
$ctag = lc($name);
}
foreach $a (@array){
print $a."<br>";
}