PHP Classes

Parsing

Recommend this page to a friend!

      crXml  >  All threads  >  Parsing  >  (Un) Subscribe thread alerts  
Subject:Parsing
Summary:Get value to array
Messages:2
Author:Xperd
Date:2011-04-12 15:46:34
Update:2011-04-18 17:40:36
 

  1. Parsing   Reply   Report abuse  
Picture of Xperd Xperd - 2011-04-12 15:46:34
Hi,

crXml is great class. I need help because I could not get right value to array.

include_once('crXml.php');
$xml = new crXml();
$data = '<?xml version="1.0" encoding="UTF-8"?'.'><records><price>12345</price></records>';
$xml->loadXML($data);
$my_array['price'] = $xml->records->price;
print_r($my_array['price']);

Value of $my_array['price'] is object, but it`s value should be 12345.

Please could you help me?

Dušan

  2. Re: Parsing   Reply   Report abuse  
Picture of Sandeep.C.R Sandeep.C.R - 2011-04-18 17:40:36 - In reply to message 1 from Xperd
hi,

sorry for the late reply...

can you please try casting the value to a string

$my_array['price'] = (string) $xml->records->price;

regards,
sandeep.