• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1322
  • Last Modified:

XML declaration allowed only at the start of the document

This website:
http://validator.w3.org/

found the following error:

Line 3, Column 5: XML declaration allowed only at the start of the document <?xml version="1.0" encoding="utf-8"?>

for the HTML file starting with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">

I'm confused abouit why...

Any idea?
0
newbieweb
Asked:
newbieweb
2 Solutions
 
jessc7Commented:
The XML Declaration is required to be the first line on an XML-based file. This is the way the XML standard was written, to let the XML parser know what version of XML the structure conforms to, the encoding, and whether it is standalone:

http://xmlwriter.net/xml_guide/xml_declaration.shtml
0
 
varontronCommented:
The xml declaration
<?xml version="1.0" encoding="utf-8"?>

Open in new window


must be the first line in the document.

Try tihs

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Open in new window


See examples here:
http://en.wikipedia.org/wiki/Document_Type_Definition

Dave
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now