PHP code example of rain_sunshine_cloud / xml

1. Go to this page and download the library: Download rain_sunshine_cloud/xml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rain_sunshine_cloud / xml example snippets


    $array = ["from"=>2,"to"=>true,"message"=>["sdf" => "1sdf"]];
    $json = "{"2":"1"}";
    $object = new Object();
    $str = "skdjfk";
    $str = Xml::encode($json,'xml'); //转为xml格式,不带声明
    $str = Xml::encode($json,'xml',true); //转为xml格式,带声明

Xml::setFile("php://input"); 
$array = Xml::toArray();//转为Array格式
$object = Xml::toObject();//转为Object格式
$object = Xml::toObject(null,"xml");//转为Object并添加至xml对象内
$Josn = Xml::toJson('');//转为Object并添加至xml对象内