PHP | XMLWriter endElement()函数
XMLWriter::endElement()函数是PHP中的一个内置函数,用于结束使用XMLWriter::startElement()函数启动的当前元素。
句法:
bool XMLWriter::endElement( void )
参数:此函数不接受任何参数。
返回值:此函数在成功时返回 TRUE,在失败时返回 FALSE。
下面的示例说明了PHP中的XMLWriter::endElement()函数:
示例 1:
openURI('php://output');
// Start the document
$writer->startDocument('1.0', 'UTF-8');
// Start a element
$writer->startElement('strong');
// Add value to the element
$writer->text('GeeksforGeeks in bold.');
// End the element
$writer->endElement();
// End the document
$writer->endDocument();
?>
输出:
GeeksforGeeks in bold.
示例 2:
openURI('php://output');
// Start the document
$writer->startDocument('1.0', 'UTF-8');
// Start a element
$writer->startElement('div');
// Write the attribute
$writer->writeAttribute('style', 'color:red');
// Add value to the element
$writer->text('Red GeeksforGeeks');
// End the element
$writer->endElement();
// Start a element
$writer->startElement('mark');
// Add value to the element
$writer->text('Marked GeeksforGeeks');
// End the element
$writer->endElement();
// End the document
$writer->endDocument();
?>
输出:
参考: https://www. PHP.net/manual/en/函数.xmlwriter-end-element。 PHP