xp-framework/xml 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

xp-framework/xml

最新稳定版本:v12.0.0

Composer 安装命令:

composer require xp-framework/xml

包简介

XML APIs for the XP Framework

关键字:

README 文档

README

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

The xml package provides APIs to handle XML.

XML data

Most of the time, XML is used to hold data. In this case, a fully blown DOM api is too much overhead to work with the data. This is where the xml.Tree class comes in.

This example will print out a nicely formatted XML document:

use xml\{Tree, Node};

$t= new Tree('customer');
$t->root()->setAttribute('id', '6100');
$t->addChild(new Node('name', 'Timm Übercoder'));
$t->addChild(new Node('email', 'uebercoder@example.com'));

echo $t->getSource(INDENT_DEFAULT);

XSL Transformation

The DomXSLProcessor class uses LibXSLT and thus supports EXSLT features like user functions, callbacks, string functions, dynamic evaluation and more.

A simple example:

use xml\DomXSLProcessor;
use xml\TransformerException;
use util\cmd\Console;

$proc= new DomXSLProcessor();
$proc->setXSLFile('test.xsl');
$proc->setXMLFile('test.xml');

try {
  $proc->run();
} catch (TransformerException $e) {
  // Handle
}

Console::writeLine($proc->output());

XPath queries

use xml\XPath;
use util\cmd\Console;

$xml= '<dialog id="file.open">
 <caption>Open a file</caption>
   <buttons>
     <button name="ok"/>
     <button name="cancel"/>
   </buttons>
</dialog>';

Console::writeLine((new XPath($xml))->query('/dialog/buttons/button/@name')));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-01-10