Page 1 of 1

How do output data from another PHP file?

Posted: Wed Jul 21, 2010 3:19 am
by uusrand
Hallo!

How do output data from another PHP file "1.php" (file is with XML construction).

"1.php" code:
<meteodata time="2010-07-21">
<data id="temp">23.35</data>
<data id="humid">72.14</data>
</meteodata>

On file "2.php" should be a lines what print the data of "temp" and "humid"
echo "<a href=\"http://.../1.php" </a>";

Re: How do output data from another PHP file?

Posted: Wed Jul 21, 2010 3:40 am
by Gargoyle

Code: Select all

echo file_get_contents('1.php');
note that you will have to address the file through http unless you want the php code.

Re: How do output data from another PHP file?

Posted: Wed Jul 21, 2010 5:43 am
by uusrand
Thanks.

But how can I get only data, if example data id="temp"

Re: How do output data from another PHP file?

Posted: Wed Jul 21, 2010 5:50 am
by Gargoyle
so you actually want to parse XML data?

check this out:
http://www.php.net/manual/en/ref.xml.php