blob: 7c0101480884af46d9dfc7630208ee1e96287858 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
--TEST--
DOM Document: saveXML with createElement and formatOutput
--CREDITS--
CHU Zhaowei <jhdxr@php.net>
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$dom = new domDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$root = $dom->createElement('root');
$dom->appendChild($root);
$child1 = $dom->createElement('testsuite');
$root->appendChild($child1);
$child11 = $dom->createElement('testcase');
$child11->setAttribute('name', 'leaf1');
$child12 = $dom->createElement('testcase');
$child12->setAttribute('name', 'leaf2');
$child1->appendChild($child11);
$child1->appendChild($child12);
echo $dom->saveXml();
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<root>
<testsuite>
<testcase name="leaf1"/>
<testcase name="leaf2"/>
</testsuite>
</root>
|