The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
DKP Log Parser 1.4.1c (Default branch) iBot Software Releases - RSS News 0 05-07-2008 07:00 PM
Text Parser karthikn7974 Shell Programming and Scripting 8 04-22-2008 05:16 AM
xml parser in perl zedex Shell Programming and Scripting 1 03-29-2008 11:37 AM
string parser flextronics Shell Programming and Scripting 8 08-28-2006 04:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-31-2008
vincaStar vincaStar is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
Perl XML:Parser help

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="&quot;$&quot;#,##0_);[Red]\(&quot;$&quot;#,##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>";
}

Last edited by Yogesh Sawant; 03-31-2008 at 01:22 AM.. Reason: added code tags
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0