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

my code output is in xml not in json

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 ?

So , is this solved ?

Be a part of the DaniWeb community

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