Send to GeoRSS with php

Send to GeoRSS with php

Page 1 of 1

5 Replies - 3186 Views - Last Post: 22 April 2010 - 07:53 AM Rate Topic: -----

#1 Guest_Sebastian*


Reputation:

Send to GeoRSS with php

Posted 22 April 2010 - 06:35 AM

This is my code.

<?php


$xml=simplexml_load_file('geo.xml');
$channel=$xml->channel->addChild('item');
$channel->addChild('title',$_POST['name']);
$channel->addChild('description',$_POST['description']);
$lnglat=$_POST['txtLng']. ' '.$_POST['txtLat'];
$channel->addChild('georss:point', $lnglat);

$xml->asXML('geo.xml');

echo 'du har nu lagt till uppgifter i xml filen';
?>

And this is my error code.

Fatal error: Call to a member function addChild() on a non-object in /home/student/h08sebbo/google/addToXML.php on line 17

Is This A Good Question/Topic? 0

Replies To: Send to GeoRSS with php

#2 Arenlor   User is offline

  • D.I.C Regular
  • member icon

Reputation: 38
  • View blog
  • Posts: 427
  • Joined: 26-April 06

Re: Send to GeoRSS with php

Posted 22 April 2010 - 07:18 AM

Please use code tags, it makes it easier for us to read. Also, please post the full code, or at least point out which line is line 17. Also read up on namespace with: http://us3.php.net/m...nt.addChild.php
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Sebastian*


Reputation:

Re: Send to GeoRSS with php

Posted 22 April 2010 - 07:24 AM

PHP File

<?php


$xml=simplexml_load_file('geo.xml');

$channel=$xml->channel->addChild('item');
$channel->addChild('title',$_POST['name']);
$channel->addChild('description',$_POST['description']);
$lnglat=$_POST['txtLng']. ' '.$_POST['txtLat'];
$channel->addChild('georss:point', $lnglat);

$xml->asXML('geo.xml');

echo 'du har nu lagt till uppgifter i xml filen';
?>




geo.xml code
<?xml version="1.0" encoding="iso-8859-1"?>
<rss xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
	<title>Karta</title>
	<link>http://www.falun.se</link>
	<description>
		<![CDATA[
		Karta over Falun.
		]]>
	</description>
	<language>se</language>

	<webMaster/>
	<copyright/>
	<pubDate>2010-04-20</pubDate>


	<item>
		<title>Järlinden</title>
		<description>

		<![CDATA[
		En fin kommentar också.<br/>
		
		<img src="http://www.iconspedia.com/uploads/1659801417.png">
		]]>
		</description>
		<link>http://www.svenskakyrkan.se/</link>		
		<geo:lat>60.616712677062026</geo:lat>
		<geo:long>15.664615631103516</geo:long>
	</item>


</channel>



Was This Post Helpful? 0

#4 Arenlor   User is offline

  • D.I.C Regular
  • member icon

Reputation: 38
  • View blog
  • Posts: 427
  • Joined: 26-April 06

Re: Send to GeoRSS with php

Posted 22 April 2010 - 07:32 AM

I have to assume that line 17 is the one with georss:point. If it's not then I can not help you any further until I get either your full source code or some indication of which one is line 17. Try this:
$channel->addChild('point', $lnglat, 'geo');

Looking at your XML I think you meant to use geo, not georss as your namespace, correct it if you meant georss.
Was This Post Helpful? 0
  • +
  • -

#5 Guest_Sebastian*


Reputation:

Re: Send to GeoRSS with php

Posted 22 April 2010 - 07:47 AM

$channel=$xml->channel->addChild('item');

Thats my line 17.
Was This Post Helpful? 0

#6 Arenlor   User is offline

  • D.I.C Regular
  • member icon

Reputation: 38
  • View blog
  • Posts: 427
  • Joined: 26-April 06

Re: Send to GeoRSS with php

Posted 22 April 2010 - 07:53 AM

Try removing the channel-> and see if it helps. I'm not familiar with SimpleXML, but that doesn't seem to be right.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1