What is the difference between
<?xml version="1.0"?>
and
<xml version="1.0">
Why does it look like shorthand PHP in the XML tag? I'm sure that's what it is but why is it there?
I have an XML file that is throwing an error, but I couldn't find the error and now I'm assuming it's the ?
in the XML tag?
<?xml version="1.0"?>
is an XML declaration. It is an optional indication of the version of XML, the character encoding, and the standalone document declaration. It can only appear as the very top of an XML file, if anywhere, and may not be repeated.
<xml version="1.0">
is an open tag (that will require a closing tag) to an XML element. While it would be well-formed (if properly closed), do not use this -- it looks too much like an bungled XML declaration. Moreover, the W3C XML Recommendation states:
Names beginning with the string
"xml"
, or with any string which would match(('X'|'x') ('M'|'m') ('L'|'l'))
, are reserved for standardization in this or future versions of this specification.
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