How you would start depends on how the data is returned to you. Once you have it assigned to a php $variable, you can do something like this:
PHP Code:
$xmlString = '<recharge><status>SUCCESS</status><txId>12544172981250</txId><balance>1000</balance><discountprice>980</discountprice></recharge>';
$X = new SimpleXMLElement($xmlString);
// assuming there is only one set of elements,
// and there is only one of each element,
// you can access them directly fairly easily:
print $X->status; // prints "SUCCESS"
// or assign them to variables
$status = $X->status; // $status holds value 'SUCCESS'
If you have more complex XML structures, or if you need to modify or re-save the XML tree, it gets significantly more complex.
In addition, while you may be tempted to think of the SimpleXML Object ( $X in the example above) as a variable or an array, it is not. Objects are fundamentally different, and you'll run into problems fairly quickly if you don't read up and learn about how to handle them. SimpleXML is the easiest library I've used (far better than DomDocument), but it's isn't really "simple." As djr says, you need to have an understanding of how to use object-oriented PHP before this will make any sense to you.
Bookmarks