473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XML - PHP4?

Hi All,

I am trying to get the value of a specific node in an XML file. My
code is below, I have added comments pointing out where I believe the
problem to be, specifically on this line:

$coordinates = $xml->Response->Placemark->Point->coordinates;

Which, for some reason is empty. I am running PHP4, is this possible
in 4? You will notice I have replaced one of the lines which only
worked with PHP5 (SimpleXMLElement).

Note that my code was based on this sample:
http://www.developer.com/db/article.php/3621981

I later looked at this one from the Google maps API documentation
http://code.google.com/support/bin/a...00&topic=11364

I can confirm that the XML is returned and valid.

Any help/suggestions much appreciated - I sat down 3hrs ago thinking
this would be a 30 min job! :o)

Thank you!
Simon.
<?php

// Your Google Maps API key
$key = "<MYGOOGLEAPICODE>";

// Desired address
$address = "http://maps.google.co.uk/maps/geo?q=<SOME POST
CODE>&output=xml&key=$key";

// Retrieve the URL contents
$page = file_get_contents($address);

// Parse the returned XML file
// $xml = new SimpleXMLElement($page); <-- PHP 5 Required
$xml = domxml_open_mem($page);

// Parse the coordinate string
$coordinates = $xml->Response->Placemark->Point->coordinates;
<---- This var is empty
$coordinatesSplit = split(",", $coordinates);

// Format: Longitude, Latitude, Altitude
$lat = $coordinatesSplit[1];
$lng = $coordinatesSplit[0];

// Diags
print "lat" . $lat;
print "lng" . $lng;

print $coordinates; <---- Outputs nothing

?>
Jun 27 '08 #1
4 1709
..oO(TisMe)
>I am trying to get the value of a specific node in an XML file. My
code is below, I have added comments pointing out where I believe the
problem to be, specifically on this line:

$coordinates = $xml->Response->Placemark->Point->coordinates;

Which, for some reason is empty. I am running PHP4, is this possible
in 4? You will notice I have replaced one of the lines which only
worked with PHP5 (SimpleXMLElement).
And do you still use Windows 95?

Update to PHP 5 as soon as possible. The support for PHP 4 will finally
end in a few weeks. There's no point in using it anymore. Most of the
scripts written for PHP 4 will also work on PHP 5 without any problems,
if they were written properly.

Micha
Jun 27 '08 #2
On Tue, 24 Jun 2008 12:02:48 -0700, TisMe <si**********@googlemail.com>
wrote:
Hi All,

I am trying to get the value of a specific node in an XML file. My
code is below, I have added comments pointing out where I believe the
problem to be, specifically on this line:

$coordinates = $xml->Response->Placemark->Point->coordinates;

Which, for some reason is empty. I am running PHP4, is this possible
in 4? You will notice I have replaced one of the lines which only
worked with PHP5 (SimpleXMLElement).

Note that my code was based on this sample:
http://www.developer.com/db/article.php/3621981

I later looked at this one from the Google maps API documentation
http://code.google.com/support/bin/a...00&topic=11364

I can confirm that the XML is returned and valid.

Any help/suggestions much appreciated - I sat down 3hrs ago thinking
this would be a 30 min job! :o)

Thank you!
Simon.
<?php

// Your Google Maps API key
$key = "<MYGOOGLEAPICODE>";

// Desired address
$address = "http://maps.google.co.uk/maps/geo?q=<SOME POST
CODE>&output=xml&key=$key";

// Retrieve the URL contents
$page = file_get_contents($address);

// Parse the returned XML file
// $xml = new SimpleXMLElement($page); <-- PHP 5 Required
$xml = domxml_open_mem($page);

// Parse the coordinate string
$coordinates = $xml->Response->Placemark->Point->coordinates;
<---- This var is empty
$coordinatesSplit = split(",", $coordinates);

// Format: Longitude, Latitude, Altitude
$lat = $coordinatesSplit[1];
$lng = $coordinatesSplit[0];

// Diags
print "lat" . $lat;
print "lng" . $lng;

print $coordinates; <---- Outputs nothing

?>
You didn't do any error checking for domxml_open_mem. Check to see if
that's the source of the problem.

if ( !$dom = domxml_open_mem($str) ) {
echo 'Error parsing';
exit;
}

---
Curtis, http://dyersweb.com
Jun 27 '08 #3
You didn't do any error checking for domxml_open_mem. Check to see if *
that's the source of the problem.

if ( !$dom = domxml_open_mem($str) ) {
* * echo 'Error parsing';
* * exit;

}
Micha - Thank you, but PHP4 is capable of what I need to do, I will
consider PHP5 soon, but not right now.

Curtis - Thanks, I tried that and the XML does parse Ok, so the XML is
valid.

Any other ideas?
Jun 27 '08 #4
..oO(TisMe)
>Micha - Thank you, but PHP4 is capable of what I need to do,
PHP 4 is dead. There won't be any more security updates for it.
It was more than enough time to upgrade.
>I will
consider PHP5 soon, but not right now.
OK, but _do_ it. It's a must.

Micha
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nisha_tm | last post by:
Hello: I have a form in which I have checkboxes. Right now, I wrote the form's html and the php4 script. I use associative arrays in the form to capture the checkboxes that are checked. My...
0
by: Klaus Boehmer | last post by:
Hello, I'm trying to install gd2 with gif-support as an extension with php4. I compiled the patched version of gd2 - fine. I compiled php4 with gd=shared - fine. I installed it and restarted...
1
by: Erik | last post by:
I understand, that PHP4 has a MySQL client built in. I was warned, that this client does not support the MySQL 4.1.1 system, which I installed on my RH9 box end that I need to install that version...
5
by: Tim Tyler | last post by:
I'm sure this is a FAQ - but I could not find a coherent statement of the answer: Some of my clients want PHP4. Other ones want PHP5. Can I run both PHP4 and PHP5 under the same instance of...
0
by: Dave Pham | last post by:
I just cleaned my comp, and I am trying to re-config my webserver... I am trying to setup apache 2 so it runs both php4 and php5, I also have two instances of mysql running. I know this can be...
1
by: porneL | last post by:
I've had setup on WinXP: Apache1.3 with PHP4 module and PHP5 installedas CGI for one vhost. This worked fine, till I installed Zend Studio 4 beta. I'm trying to make Zend Server use my...
2
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different...
12
by: Drazen Gemic | last post by:
How long will PHP4 be supported ? When is PHP4 end of life scheduled ? DG
3
by: doctorhardik | last post by:
hai all i am try configure php4.3.9 on my FC-3 machine. and my mysql database version 5.0.1, in phpinfo file it show mysql but when i run php -v command it show error like
8
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.