I'm creating a xml using this
$customXML = new SimpleXMLElement('<abc></abc>');
after adding some attributes onto this, when I try to print it it appears like this,
<?xml version="1.0"?> <abc id="332"><params><param name="aa">33</param></params></abc>
Is there a way to remove the xml version node ? Thank you
If you want to remove the spaces before the tag you can use the following instead: find [\t ]*<time>[0-9A-Z:-]*</time> replace with blank. Thanks that works for me!
The version=”1.0″ is the version of the XML currently used. There are various versions of XML available. The encoding= ”UTF-8″ specifies the character encoding used while writing an XML document, for example, êèé is for French and so on. Its default value is “UTF-8”.
<? xml version="1.0" encoding="UTF-8"?>
What is an XML Parser? To read and update, create and manipulate an XML document, you will need an XML parser. In PHP there are two major types of XML parsers: Tree-Based Parsers. Event-Based Parsers.
In theory you can provide the LIBXML_NOXMLDECL
option to drop the XML declaration when saving a document, but this is only available in Libxml >= 2.6.21 (and buggy). An alternative would be to use
$customXML = new SimpleXMLElement('<abc></abc>'); $dom = dom_import_simplexml($customXML); echo $dom->ownerDocument->saveXML($dom->ownerDocument->documentElement);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With