Christopher:

On Tue, Apr 09, 2002 at 09:25:07AM -0400, Crane, Christopher wrote:

> The problem is now back to the beginning, I can not get the $Line value,
> which is the data I want to be pushed into an array. I did not get an error
> with the code below, but I did not get any information when printing the
> array.
... snip ...
> function StartHandler($Parser, $ElementName, $Attr='') { print
> "<b>$ElementName:</b> "; }

Allow me to nit pick.  That's hard to read.  This, on the other hand, is
clearer:
   function StartHandler($Parser, $ElementName, $Attr='') {
      print "<b>$ElementName:</b> ";
   }
Of course, you can do what you want, but then again, you're asking the 
public to look at your code.  Let alone, using standard indentation 
makes the code easier for you to understand as well...


> function CharacterHandler($Parser, $Line) { array_push($StockStuff, $Line);
> print "$Line<br>\n"; }

You need to global the $StockStuff array in order for it to be available 
both inside and outside the function.


> while ( list(,$Sym) = each($Symbols) ) {
>    $Contents = implode( '', file("$URI$Sym") );
>  
>    $Parser = xml_parser_create('ISO-8859-1');
>    xml_set_element_handler($Parser, 'StartHandler', 'EndHandler');
>    xml_set_character_data_handler($Parser, 'CharacterHandler');
>  
>    if ( xml_parse($Parser, $Contents) ) { echo 'YES!<br>'; }
>    else { echo 'NO!<br>'; }
>  
>    xml_parser_free($Parser);
>  
>  }
> 
> print "1st Position in the array = $StockStuff[0]<br>\n";

You'll want to move this up into the while loop so it will do what you
want each time a file is parsed.

Similarly, don't forget to redeclare your $StockStuff array before
parsing the next file, otherwise you'll be sticking the new file's
contents at the end of all the other files' contents.  So, rather than 
putting the line
   $StockStuff = array();
at the beginning of the script, put it just inside the beginning of the 
while loop.

Enjoy,

--Dan

PS:  Be kind when posting.  Delete quoted text that's not necesary.

-- 
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to