xml output:

<balance>
<credits>39660</credits>
</balance>

how to fetch the xml output from url and store the credits i.e. 39660 into php variable.
the above xml output is coming from following url

http://www.xyz.com/check-balance.php?username=ssgent&password=ssgentr

check-balance.php code:

<?php
require('dbcon.php');
include('encrypt.php');
include('functions.php');
$username = $_GET['username'];
$password = $_GET['password'];
$password = encrypt($password, 'riffre');
$url = $_SERVER['HTTP_HOST'];
$url_length = strlen($url);

if (substr($url, 0, 4) == 'www.') {
    $url_length = $url_length - 4;
    $url = substr( $url, 4, $url_length );
}


$query = "select * from users where username='$username' and password='$password' and status='Active'";

if(!($result = mysql_query($query))) {
    exit(mysql_error());
    (bool)true;
}
$crq=mysql_fetch_array($result);
$userid = $crq['id'];

$rows = mysql_num_rows($result);
if ($rows != 1) {
    echo 'Invalid Credentials.';
    return 1;
}
else
{
$avail = check_user_credit($userid);

header('Content-Type: application/xml');
echo "<balance><credits>$avail</credits></balance>";
}
?>

hope some one will resolve this issue.

thanks in advance

Re: how to store xml output into variable 80 80

my code output is in xml not in json

Re: how to store xml output into variable 80 80

Yes you are right ;) . Then @see http://php.net/manual/en/simplexml.examples-basic.php (of course you will add an ?xml start tag (as in the example there) and also var_export first the results to be sure what you got).

Just a question did you Googled it ?

Re: how to store xml output into variable 80 80

yes

Re: how to store xml output into variable 80 80

So , is this solved ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.