tonivdv/php-dom-utils

提供了一种简单的方式来填充 DOMDocument 对象的数组

dev-master 2015-07-14 07:08 UTC

This package is auto-updated.

Last update: 2024-09-18 08:15:22 UTC


README

Build Status

提供了一种简单的方式来填充 DOMDocument 对象的数组

$array = array(
  "nodes" => array(
    "node" => array(
      0 => "text1",
      1 => "text2"
    )));

$dom = new \DOMDocument('1.0', 'utf-8');

PhpDomUtils::fillDom($dom, $array);

echo $dom->saveXML();

上述示例的输出为

<?xml version="1.0" encoding="utf-8"?>
<nodes>
  <node>text1</node>
  <node>text2</node>
</nodes>