定制 pn/epp-xml2array 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pn/epp-xml2array

Composer 安装命令:

composer require pn/epp-xml2array

包简介

XML/EPP to a simple readable array, including Namespace and CDATA support

README 文档

README

An EPP (http://en.wikipedia.org/wiki/Extensible_Provisioning_Protocol), with Namespace support, to a simple Array. Still usable for normal XML too. CDATA is supported.

Why not use xyz?

For regular XML you can use this (probably) fine:

$xml = simplexml_load_string($xmlstring);
$json = json_encode($xml);
$array = json_decode($json,TRUE);

But it doesn't work "out of the box" with namespaces. Also, simplexml_load_string somehow removes certain attributes. For example, if your EPP had:

<domain:contact type="billing">P-ABC120</domain:contact>

It will remove the "type" attribute. And for EPP any missing information makes those methods unusable.

How to use

First, load the XML:

PN\Xml2Array::loadXML($xml_string);
//or
PN\Xml2Array::loadXML(file_get_contents('somefile.xml'));

Get the whole array from your complete EPP string:

print_r( PN\Xml2Array::getArray() );

Get all the Namespace prefixes + URI's as an array:

print_r( PN\Xml2Array::getNamespaces() );

Get a part of the EPP in array by giving the prefix:

print_r( PN\Xml2Array::getArrayNS('contact') );
Added in v1.1

Too lazy to look where in the array/xml a tag is? Or the tag could be changing in different xml files? See example1.php, use it like this:

print_r( PN\Xml2Array::getArrayElement('domain', 'pw', true ) );
Added in v1.3

Want to get an attribute like:

<result code="1000">...

See example1.php, use it like this:

print_r( Xml2Array::getArrayAttribute(null, 'result', 'code', true) );

Simple as that.

License

MIT

统计信息

  • 总下载量: 7.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固