Thursday, November 15, 2012

xml data in php and javascript

I\’m a php and javascript newbie so don\’t be mad.

Ok so i want to get xml file from another server and then extract only one data(number) and put it in javascript variable so i can calculate with it.


I have this code that gets xml file fine, and i get $result variable with data that i need, but i can\’t save that data in javascript variable.

The reason i need this number in javascript is because all of calculations are coded in javascript.


this is php code:



<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
\'http://www.pbz.hr/Downloads/PBZteclist.xml\');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($ch);

echo($xml);

curl_close($ch);

$xmlObject = new SimpleXMLElement($xml);
$node = $xmlObject->children();
$result = $node[0]->Currency[12]->BuyRateForeign;
echo(\"<br />\");
echo(\"<br />\");
echo $result;
?>


I need data from EUR7,480000


That number 7,480000 is all i need to extract and save in javascript variable.


Maybe the way i\’m doing this isn\’t right, but i have tryied everything. Please help me.






Rating: out of 5 based on ratings



The post xml data in php and javascript appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/xml-data-in-php-and-javascript.html

No comments:

Post a Comment