CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
XML::Parser help

 



tiffbrink
New User

Mar 31, 2008, 1:41 PM

Post #1 of 3 (1769 views)
XML::Parser help Can't Post

In the case that there are two cells under one row, I can only read the first cell. If anyone thinks they know how to deal with this please let me know...or another place that I can go to get help?

#XML code:
<Row>
<Cell><Data ss:Type="String">Loved</Data></Cell>
<Cell ss:Index="3"><Data ss:Type="Number">3.0</Data></Cell>
</Row>
<Row>
<Cell ss:MergeAcross="1"><Data ss:Type="String">12-18 months</Data></Cell>
</Row>

#Perl code:
use XML::Parser;
$xp=new XML::Parser();
$xp->setHandlers(Start => \&start, End => \&end, Char => \&cdata);
$xp->parsefile("test.xml";
$flag=$hst=$hster=$hsted=0;
$manu=$prod=$image=$desc=$price=$cat=0;
$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>";
}


#OUTPUT:
Loved
12-18 months


KevinR
Veteran


Mar 31, 2008, 1:46 PM

Post #2 of 3 (1767 views)
Re: [tiffbrink] XML::Parser help [In reply to] Can't Post

I just posted a reply to this same question on unix.com
-------------------------------------------------


tiffbrink
New User

Mar 31, 2008, 2:08 PM

Post #3 of 3 (1765 views)
Re: [KevinR] XML::Parser help [In reply to] Can't Post

Hey! Thanks for the reply. Although that was the problem the fix was a little different...used if (lc($target)){ and it worked perfectly.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives