xref: /php-src/ext/xmlwriter/tests/003.phpt (revision 74859783)
1--TEST--
2XMLWriter: libxml2 XML Writer, membuffer, flush, attribute
3--EXTENSIONS--
4xmlwriter
5--FILE--
6<?php
7
8$xw = xmlwriter_open_memory();
9xmlwriter_start_document($xw, '1.0', 'UTF-8');
10xmlwriter_start_element($xw, "tag1");
11
12
13$res = xmlwriter_start_attribute($xw, 'attr1');
14xmlwriter_text($xw, "attr1_value");
15xmlwriter_end_attribute($xw);
16
17xmlwriter_write_attribute($xw, "att2", "att2_value");
18xmlwriter_text($xw, "Test text for tag1");
19$res = xmlwriter_start_element($xw, 'tag2');
20if ($res < 1) {
21    echo "StartElement context validation failed\n";
22    exit();
23}
24xmlwriter_end_document($xw);
25
26// Force to write and empty the buffer
27echo xmlwriter_flush($xw, true);
28?>
29--EXPECT--
30<?xml version="1.0" encoding="UTF-8"?>
31<tag1 attr1="attr1_value" att2="att2_value">Test text for tag1<tag2/></tag1>
32