TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 11-18-2007, 09:53 PM   #1 (permalink)
The Visitor
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
joby1 is on a distinguished road
Angry alternative to simplexml command in php4, HELP!!!

just found out my server doesn't have php5 and doesn't plan to for months.

am trying to make a geocoding parsing script (i am very newbie to all this)

there is a great php geocde script here - http://www.developer.com/db/article.php/3621981
but uses simplexml command (line 19) that is not used by php4

found this as a possible alternative for simplexml command-
http://www.shop24-7.info/32-0-simple...tive-php4.html

but being a newbie am clueless how to do it, but i tried to no avail....

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<?php

    
class sxml
{
    var 
$parser;
    var 
$error_code;
    var 
$error_string;
    var 
$current_line;
    var 
$current_column;
    var 
$data = array();
    var 
$datas = array();
    function 
parse($data)
    {
        
$this->parser xml_parser_create('UTF-8');
        
xml_set_object($this->parser$this);
        
xml_parser_set_option($this->parserXML_OPTION_SKIP_WHITE1);
        
xml_set_element_handler($this->parser'tag_open''tag_close');
        
xml_set_character_data_handler($this->parser'cdata');
        if (!
xml_parse($this->parser$data))
        {
            
$this->data = array();
            
$this->error_code xml_get_error_code($this->parser);
            
$this->error_string xml_error_string($this->error_code);
            
$this->current_line xml_get_current_line_number($this->parser);
            
$this->current_column xml_get_current_column_number($this->parser);
        }
        else
        {
            
$this->data $this->data['child'];
        }
        
xml_parser_free($this->parser);
    }

    function 
tag_open($parser$tag$attribs)
    {
        
$this->datas[] =& $this->data;
        
$this->data =& $this->data['child'][$tag][];
    }

    function 
cdata($parser$cdata)
    {
        @
$this->data['data'] .= $cdata;
    }

    function 
tag_close($parser$tag)
    {
        
$this->data =& $this->datas[count($this->datas)-1];
        
array_pop($this->datas);
    }
}

   
// Your Google Maps API key
   
$key "***have removed my google api key but it was in here!!!***";

   
// Desired address
   
$address "http://maps.google.com/maps/geo?q=411+Woody+Hayes+Drive,+Columbus,+OH&output=xml&key=$key";

   
//// Retrieve the URL contents
//   $page = file_get_contents($address);
//
//   // Parse the returned XML file
//   $xml = new SimpleXMLElement($page);
    
    //Demo: Einsatz von sxml

        
$url=$address;

        
$xml_parser = new sxml;
        
$src=implode (''file ($url));
        
$xml_parser->parse($src);
        
$xml=$xml_parser->data;

       
// print_r($xml);
        
   /// Parse the coordinate string
    
list($longitude$latitude$altitude) = explode(","
     
$xml->Response->Placemark->Point->coordinates);

    
// Output the coordinates
    
echo "Longitude: $longitude, Latitude: $latitude";
    
    
    
    

?>

<body>
</body>
</html>
Anyone able to spot the mistake???? just want it to echo the results, will then be using the extended script on page 2 of the first link to mysql it....

Please help.

thanks in advance
joby1 is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB 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. The time now is 08:07 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design