The World’s Largest Online Community for Developers

'; xml - how make node like this <node/> with php xmlwriter - LavOzs.Com

i need make a xml with php code, but i dont now how make a single node like <node/> using the xmlwriter method. example


Thanks in advance

<node-name/> is just an optimization. If an element node has no child nodes (elements, text, comments, ...). it can be closed directly. For the parser it is the same as <node-name></node-name>.

The serializer will apply that optimization by default. However if you add an empty string as content you will create a text child node and block the optimization:

$writer = new XMLWriter();

// element with content
$writer->writeElement('element', 'one');
// empty element
// element with empty child node
$writer->writeElement('another_element', '');



<?xml version="1.0"?>
How can I prevent SQL injection in PHP?
Deleting an element from an array in PHP
Secure hash and salt for PHP passwords
How do I make a redirect in PHP?
How do I comment out a block of tags in XML?
How do you parse and process HTML/XML in PHP?
Reference — What does this symbol mean in PHP?
Why shouldn't I use mysql_* functions in PHP?
How do I pass variables and data from PHP to JavaScript?