Forum Moderators: coopster

Message Too Old, No Replies

Proceed data obtained by HTTP GET method

Proceed data obtained by HTTP GET method

         

finita

2:48 am on Dec 13, 2006 (gmt 0)

10+ Year Member



Hi,

I have following problem:

I'm getting xml data by html get method. For ex.

[somesite.com...]

When I send this info I'm getting response data as xml

Now my question and problem is:
After getting this xml tree I want to parse it and write to db.
Or after getting it I want to save somewhere in server as *.xml file.

Is it possible?

eelixduppy

2:55 am on Dec 13, 2006 (gmt 0)



Welcome to WebmasterWorld!

>>>parse it and write to db
For this I suggest SimpleXML [us2.php.net] and then writing the content using the specific database functions. I'm guessing mysql?

>>>save somewhere in server as *.xml file.
Get the xml file from and if you have php 5, you can use file_put_contents [us2.php.net], if not use fwrite [us2.php.net].

Hope this explains something :)

finita

5:14 am on Dec 13, 2006 (gmt 0)

10+ Year Member



Thanks for your reply.

But I think I could not explain what I need.

When I press submit get mirror in response.php

All right I can save from browser as xml file.
But I dont want to save it manually. I need to get this mirror and save automatically to my server. I'm getting the results from other server which I can reach only by this way.

So my question is how can i save it as xml in my server?

[edited by: coopster at 6:14 pm (utc) on Dec. 13, 2006]
[edit reason] removed url TOS [webmasterworld.com] [/edit]

mcibor

4:47 pm on Dec 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As eelix said use function

[php.net...]

<?php
$filename = 'test.xml';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
echo "The file $filename is not writable";
}
?>

Read the manual, please ;)

Michal

[edited by: coopster at 6:16 pm (utc) on Dec. 13, 2006]
[edit reason] Made the "read the manual" even nicer than it was [/edit]