PDA

View Full Version : Java: Writing XML files - V1.0 vs V1.1




wrldwzrd89
Apr 12, 2009, 08:21 PM
This has got me completely baffled. If I make an XML 1.0 file, like so:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<integer len="1">3</integer>
<string len="5">Blah!</string>
<string len="25">&lt;&gt;&amp;&apos;&quot;</string>
<double len="5">293.0</double>
</test>
... and run it through an XML validator (http://www.w3schools.com/XML/xml_validator.asp), it validates. However, I would like to use XML V1.1, by making a simple change: 1.0 becomes 1.1, like so.
<?xml version="1.1" encoding="UTF-8"?>
<test>
<integer len="1">3</integer>
<string len="5">Blah!</string>
<string len="25">&lt;&gt;&amp;&apos;&quot;</string>
<double len="5">293.0</double>
</test>
If I run this through the validator, it tells me that my XML declaration isn't well-formed, and the error is on column 16 of line 1. What is making it invalid?