XML -> PHP

It's no longer the post as well primetka for myself that would not have forgotten

simplexml_load_file("file.xml");
simplexml_load_string($xml_string);

At output you get an object with a pre-packaged xml. That's super easy and super convenient.
The only thing that should probably be noted that this method requires php5 and I understand some module, well, I have gone without a shaman. If that is not the path to the php.ini file
For example, you can write here is a simple file

$xml="<request>      
<version>1.2</version>
<result_url>http://ulove.ua//buy/</result_url>
<server_url>http://ulove.ua//buy/resultliqpay/</server_url>
<merchant_id>i4927007979</merchant_id>
<order_id>128</order_id>
<amount>12</amount>
<currency>USD</currency>
<description>uLove</description>
<default_phone>+380938729936</default_phone>
<pay_way>card</pay_way> 
</request>";
$xml=simplexml_load_string($xml);
print_r($xml);
echo $xml->order_id;

On the screen we

SimpleXMLElement Object
(
    [version] => 1.2
    [result_url] => http://ulove.ua//buy/
    [server_url] => http://ulove.ua//buy/resultliqpay/
    [merchant_id] => i4927007979
    [order_id] => 128
    [amount] => 12
    [currency] => USD
    [description] => uLove
    [default_phone] => +380938729936
    [pay_way] => card
)
128

My opinion, this is the easiest option, who will offer easier listen.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.