Пример #1
0
xmlwriter_start_document($xw, '1.0', 'UTF-8');
// A first element
xmlwriter_start_element($xw, 'tag1');
// Attribute 'att1' for element 'tag1'
xmlwriter_start_attribute($xw, 'att1');
xmlwriter_text($xw, 'valueofatt1');
xmlwriter_end_attribute($xw);
xmlwriter_write_comment($xw, 'this is a comment.');
// Start a child element
xmlwriter_start_element($xw, 'tag11');
xmlwriter_text($xw, utf8_encode('This is a sample text, ä'));
xmlwriter_end_element($xw);
// tag11
xmlwriter_end_element($xw);
// tag1
// CDATA
xmlwriter_start_element($xw, 'testc');
xmlwriter_write_cdata($xw, "This is a cdata content");
xmlwriter_end_element($xw);
// testctag
xmlwriter_start_element($xw, 'testc');
xmlwriter_start_cdata($xw);
xmlwriter_text($xw, "test cdata2");
xmlwriter_end_cdata($xw);
xmlwriter_end_element($xw);
// testctag
// A processing instruction
xmlwriter_start_pi($xw, 'php');
xmlwriter_text($xw, '$foo=2;echo $foo;');
xmlwriter_end_pi($xw);
xmlwriter_end_document($xw);
Пример #2
0
VERIFY(xmlwriter_full_end_element($xml));
VERIFY(xmlwriter_end_element($xml));
VERIFY(xmlwriter_start_element($xml, "node"));
VERIFY(xmlwriter_start_cdata($xml));
VERIFY(xmlwriter_text($xml, "Raw text"));
VERIFY(xmlwriter_end_cdata($xml));
VERIFY(xmlwriter_end_element($xml));
VERIFY(xmlwriter_start_element($xml, "node"));
VERIFY(xmlwriter_write_cdata($xml, "More CDATA"));
VERIFY(xmlwriter_end_element($xml));
VERIFY(xmlwriter_start_comment($xml));
VERIFY(xmlwriter_text($xml, "Comments"));
VERIFY(xmlwriter_end_comment($xml));
VERIFY(xmlwriter_write_comment($xml, "More comments"));
VERIFY(xmlwriter_start_pi($xml, "lol"));
VERIFY(xmlwriter_end_pi($xml));
VERIFY(xmlwriter_write_pi($xml, "php", "print 'Hello world!';"));
VERIFY(xmlwriter_write_raw($xml, "<node>Raw XML</node>"));
VERIFY(xmlwriter_write_dtd($xml, "name", "publicID", "systemID", "subset"));
VERIFY(xmlwriter_start_dtd($xml, "name", "publicID", "systemID"));
VERIFY(xmlwriter_end_dtd($xml));
VERIFY(xmlwriter_start_dtd_element($xml, "name"));
VERIFY(xmlwriter_end_dtd_element($xml));
VERIFY(xmlwriter_write_dtd_element($xml, "name", "content"));
VERIFY(xmlwriter_start_dtd_attlist($xml, "name"));
VERIFY(xmlwriter_end_dtd_attlist($xml));
VERIFY(xmlwriter_write_dtd_attlist($xml, "name", "content"));
VERIFY(xmlwriter_start_dtd_entity($xml, "name", false));
VERIFY(xmlwriter_end_dtd_entity($xml));
VERIFY(xmlwriter_write_dtd_entity($xml, "name", "content", false, "publicid", "systemid", "ndataid"));
VERIFY(xmlwriter_end_document($xml));