
What I would like is for the user to enter a value which I shall multiply with the current exchange rate as supplied from the rss feed.
Currently, I'm just echoing out the XML tag contents as displayed below the convert button. From this example, I only wish to get the current exchange rate which happens to be 1.20482 Euro in this example which I will then multiply.
The contents of the tag is:
<description>1 British Pound Sterling = 1.20482 Euro</description>
the same that I am echoing out. Any ideas how I can access the 1.20482 value only?
Possible Solutions:
- Is it possible to parse merely this value as oppose to everything in the XML tag?
- Would creating a substring be an option from the code that I already have?
This is the code I'm currently using to access the above tag from the RSS feed
function get_rate1(SimpleXMLElement $xml) {
$exchange['rate'] = $xml->channel->item[15]->description;
echo $exchange['rate'] . "<br />";
return $rate;
}
function get_total($exchangeRssUrl) {
// Get XML data from source
if (isset($exchangeRssUrl)) {
$feed = file_get_contents($exchangeRssUrl);
} else {
echo 'Feed not found. Check URL';
}
checkFeedExists($feed);
$xml = new SimpleXmlElement($feed);
$rate = get_rate1($xml);
return $exchange;
}
//Display Total //
function displayTotal($exchangeRate1RssUrl) {
if (isset($exchangeRate1RssUrl)) {
echo get_total($exchangeRate1RssUrl);
echo '<br />';
} else {
content_unavailable();
}
}
// Check Feed is Available
function checkFeedExists($feed) {
if (!$feed) {
die('Feed not found');
}
}
This post has been edited by NewToJava2011: 31 January 2012 - 12:32 PM

New Topic/Question
Reply



MultiQuote



|