Back to index

php5  5.3.10
xmlwriter_file.php
Go to the documentation of this file.
00001 <?php
00002 dl('xmlwriter.so');
00003 
00004 $xw = xmlwriter_open_uri('./a.xml');
00005 xmlwriter_set_indent($xw, 1);
00006 $res = xmlwriter_set_indent_string($xw, ' ');
00007 
00008 xmlwriter_start_document($xw, '1.0', 'UTF-8');
00009 
00010 // A first element
00011 xmlwriter_start_element($xw, 'tag1');
00012 
00013 // Attribute 'att1' for element 'tag1'
00014 xmlwriter_start_attribute($xw, 'att1');
00015 xmlwriter_text($xw, 'valueofatt1');
00016 xmlwriter_end_attribute($xw);
00017 
00018 xmlwriter_write_comment($xw, 'this is a comment.');
00019 
00020 // Start a child element
00021 xmlwriter_start_element($xw, 'tag11');
00022 xmlwriter_text($xw, utf8_encode('This is a sample text, รค'));
00023 xmlwriter_end_element($xw); // tag11
00024 
00025 xmlwriter_end_element($xw); // tag1
00026 
00027 
00028 // CDATA
00029 xmlwriter_start_element($xw, 'testc');
00030 xmlwriter_write_cdata($xw, "This is a cdata content");
00031 xmlwriter_end_element($xw); // testctag
00032 
00033 xmlwriter_start_element($xw, 'testc');
00034 xmlwriter_start_cdata($xw);
00035 xmlwriter_text($xw, "test cdata2");
00036 xmlwriter_end_cdata($xw);
00037 xmlwriter_end_element($xw); // testctag
00038 
00039 // A processing instruction
00040 xmlwriter_start_pi($xw, 'php');
00041 xmlwriter_text($xw, '$foo=2;echo $foo;');
00042 xmlwriter_end_pi($xw);
00043 
00044 xmlwriter_end_document($xw);