First let me thank Tyler Lane for pointing out my XML issue. I'm an idiot (= vs. ==) was holding me up. D'uh!

Now allow me to ask a Perl to PHP conversion question or three. As any Perl and PHP programmer is aware PHP does not have the cool reference thing going that Perl does (yeah, I hear the newest release of PHP is going there). It's not as bad as C++ (so I hear) but regardless it doesn't work like it does in Perl. Not complaining, just stuck (again).

Perl code:
sub {
my ($tagname, $attr) = @_;
push @state, $tagname;
if ("@state" eq "shipment package") {
        $package_id = $attr->{id};# need to convert this
        #$attr is a ref to a hash where id is the key.
}
elsif ("@state" eq "shipment package quote") {
        print "@state\n";
        %quote = ( package_id => $package_id, id => $attr->{id} );
        #need to convert the above line.
}
}, "tagname, attr"],

PHP code:
function startElement(&$Parser, &$Elem, &$Attr) {
        global $state;
        array_push ($state, $Elem);
        $states = join (' ',$state);
        if ($states == "SHIPMENT PACKAGE") {
                $package_id = $Attr->{id};//How to get the pointer to the data?
                // The value of this should be '1'
        }
        elseif ($states == "SHIPMENT PACKAGE QUOTE") {
                echo "$states\n";
//              %quote = ( package_id => $package_id, id => $attr->{id} );
        $quote = array ( package_id => $package_id, id => $attr->{id}  );
        }
}

After that, how would this convert:

$quote{class_name} = $text;
quote is a hash where class_name is the key.

Thanks again!

Reply via email to