承接 rummykhan/easy-xml 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rummykhan/easy-xml

Composer 安装命令:

composer require rummykhan/easy-xml

包简介

Convert your data to xml string easily.

README 文档

README

This package helps you in converting your data to XML easily. This package is independent of any php framework. But I took care of two popular frameworks specifically

  1. For use in Laravel
  2. For use in YII 2.0

To use in any framework

Installation

Install using composer

composer require rummykhan/easy-xml

Wit the constructor initialization you can use it any framework you may like.

$rootNode = new XmlNode('person');

$educationNode = new XmlNode('education');
$educationNode->addAttributes(['MOE' => 'SXC', 'DAE' => 'COE', 'BA' => 'UOS']);
$rootNode->addChildNode($educationNode);

$jobNode = new XmlNode('job');

$jobNode->addAttribute('first', 'https://best-bf.com');
$jobNode->addAttribute('second', 'https://infamous.ae');
$jobNode->addAttribute('third', 'https://awok.com');
$jobNode->addAttribute('fourth', 'https://helpbit.com');

$rootNode->addChildNode($jobNode)
    ->setDeclaration(XmlDeclaration::V1);

// since it implements php __toString() method
dd((string)$rootNode);
// OR
dd($rootNode->toString());

will output

<?xml version="1.0" encoding="UTF-8"?>
<person>
   <education MOE="SXC" DAE="COE" BA="UOS" />
   <job first="https://best-bf.com" second="https://infamous.ae" third="https://awok.com" fourth="https://helpbit.com" />
</person>

RummyKhan\EasyXml\XmlNode API

addChildNode

To add a child node to XmlNode. e.g.

$rootNode = new XmlNode('employees');
$employeeNode = new XmlNode('employee');

$rootNode->addChildNode($employeeNode);

setValue

To set the value of the node. Node can either have other node as children or it has a primitive value.

$rootNode = new XmlNode('name');
$rootNode->setValue('rummykhan');

addAttribute

To add the attribute for the xml node.

$rootNode = new XmlNode('person');
$rootNode->addAttribute('age', 30);

addAttributes

To add multiple attributes for the xml node. e.g.

$rootNode = new XmlNode('person');
$rootNode->addAttributes([
    'name' => 'rummykhan',
    'age' => 30
]);

setDeclaration

To set the Xml declaration

$rootNode = new XmlNode('employees');
$rootNode->setDeclaration('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>');

toString

To convert xml single node or xml node hierarchy to xml string.

$rootNode = new XmlNode('employees');
dd($rootNode->toString());

Contact

rehan_manzoor@outlook.com

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固