On Sat, Feb 10, 2001 at 07:37:32PM +0100, Steve Haemelinck wrote:
> The page I want to parse is:
>
> http://213.224.136.110:8080/test.xml
>
> And this is my code:
>
> <?php
>
> //Define Opening Tags of XML
> $open_tags = array(
> 'STORY' => '<nasdaqamex-dot-com>',
> 'STOCK_NAME' => '<issue-name>',
> 'LAST_SALE' => '<last-sale-price>',
> 'PREVIOUS_CLOSE' => '<previous-close-price>',
> 'NET_CHANGE_PCT' => '<net-change-pct>',
> 'STOCK_URL' => '<issuer-web-site-url>');
(snip)
> // handles the attributes for opening tags
> // $attrs is a multidimensional array keyed by attribute
> // name and having the value of that attribute
> function startElement($parser, $name, $attrs=''){
> global $open_tags, $temp, $current_tag;
>
> $current_tag = $name;
> if ($format = $open_tags[$name]){
> switch($name){
> case 'STORY':
> echo 'New Story: ';
> break;
> default:
> break;
> }
> }
> }
This probably isn't doing what you think it's doing. When the parser
hits a new element tag, it will pass the parser object, element name,
and its attributes to startElement(). $name will be the name of the
element. Equity-quote, issue-name, etc. So when you go to look for
$open_tags[$name], you won't find anything because the array is keyed
to STORY, STOCK_NAME, etc. It looks like you're expecting the array to
be backwards. Switching the keys/values and removing the <, /, > would
be enough to make it work.
HTH,
Matt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]