Back to index

php5  5.3.10
xmlwriter_mem.php
Go to the documentation of this file.
00001 <?php
00002 dl('xmlwriter.so');
00003 
00004 $xw = xmlwriter_open_memory();
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_text($xw, utf8_encode('This is a sample text, รค'));
00019 xmlwriter_end_element($xw); // tag1
00020 
00021 
00022 $res = xmlwriter_start_comment($xw);
00023 xmlwriter_text($xw, "Demo text comment");
00024 $res = xmlwriter_end_comment($xw);
00025 
00026 xmlwriter_end_document($xw);
00027 $out = xmlwriter_output_memory($xw, 0);
00028 
00029 echo $out;
00030 
00031 // flush the xml buffer using optional
00032 // flust argument, default is 1
00033 $out = xmlwriter_output_memory($xw, 1);
00034 echo $out;
00035 
00036 
00037 $out = xmlwriter_output_memory($xw);
00038 echo $out;
00039