PHPackages                             rain\_sunshine\_cloud/xml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rain\_sunshine\_cloud/xml

ActiveLibrary

rain\_sunshine\_cloud/xml
=========================

v1.0(7y ago)07PHPPHP &gt;=5.5.0

Since Dec 26Pushed 7y agoCompare

[ Source](https://github.com/RainSunshineCloud/xml)[ Packagist](https://packagist.org/packages/rain_sunshine_cloud/xml)[ RSS](/packages/rain-sunshine-cloud-xml/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

xml 解析和包装器
==========

[](#xml-解析和包装器)

- 支持文件读取和字符串读取

### 注意事项：

[](#注意事项)

1. 转化为xml时必须为utf-8
2. false 转为0, true转为1 null不输出
3. number类型不加CDATA,string类型加CDATA

### 用法

[](#用法)

1. 转为xml格式

```
    $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格式,带声明

```

2. 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对象内

```

3. Xml字符串转其他类型

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

```

4. 设置来源的字符集类型

```
 Xml::setCharset("gb2312");

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2697d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/041cb2d7e5d63d922726b229061fd63ca04abca4dce719fba94eb1dc4129aaea?d=identicon)[RainSunshineCloud](/maintainers/RainSunshineCloud)

---

Top Contributors

[![RainSunshineCloud](https://avatars.githubusercontent.com/u/32010961?v=4)](https://github.com/RainSunshineCloud "RainSunshineCloud (8 commits)")

### Embed Badge

![Health badge](/badges/rain-sunshine-cloud-xml/health.svg)

```
[![Health](https://phpackages.com/badges/rain-sunshine-cloud-xml/health.svg)](https://phpackages.com/packages/rain-sunshine-cloud-xml)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
