adriantreanor 1 Posted October 8, 2012 Report Share Posted October 8, 2012 (edited) Im just learning XML. I typed the following into a xml file but when I go to test it in FF it gives me the followong error although there are no errors in the xml code. Can anyone help?. The XML file still wont open in FF.Im sorry the code I was going to display: <?xml version="1.0" encoding="utf-8"?><!DOCTYPE note [<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>]><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note> Error message:XML Parsing Error: XML or text declaration not at start of entityLocation: file:///C:/xml/TMP34fh9bl3c4.xmlLine Number 1, Column 9:<body ><?xml version="1.0" encoding="utf-8"?>--------^ Im sorry but there is no body tag even if the error message says there is. <?xml version="1.0" encoding="utf-8"?><!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note> Edited October 8, 2012 by adriantreanor 1 Quote Link to post Share on other sites
Ingolme 1,020 Posted October 8, 2012 Report Share Posted October 8, 2012 The <?xml ?> declaration has to be the very first thing in the document. Where did that <BODY> tag come from? Quote Link to post Share on other sites
adriantreanor 1 Posted October 8, 2012 Author Report Share Posted October 8, 2012 Sorry I deleted the body tag but I still get an error. XML Parsing Error: not well-formedLocation: file:///C:/xml/TMP2fkdibl2fw.xmlLine Number 7, Column 30: <!ELEMENT body (#PCDATA)]>-----------------------------^ Quote Link to post Share on other sites
Ingolme 1,020 Posted October 8, 2012 Report Share Posted October 8, 2012 You have an unneeded square bracket. at the end of that line.And before the error shows up, you need another ]> after that <!ELEMENT> entity to close the <!DOCTYPE> that's at the beginning of the document. Quote Link to post Share on other sites
adriantreanor 1 Posted October 8, 2012 Author Report Share Posted October 8, 2012 The XML file still wont open in FF.Im sorry the code I was going to display: <?xml version="1.0" encoding="utf-8"?><!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>]><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note> Error message:XML Parsing Error: XML or text declaration not at start of entityLocation: file:///C:/xml/TMP34fh9bl3c4.xmlLine Number 1, Column 9:<body ><?xml version="1.0" encoding="utf-8"?>--------^ Quote Link to post Share on other sites
Ingolme 1,020 Posted October 8, 2012 Report Share Posted October 8, 2012 You still have a <body> tag before the <?xml ?> declaration. Quote Link to post Share on other sites
adriantreanor 1 Posted October 8, 2012 Author Report Share Posted October 8, 2012 (edited) Im sorry but there is no body tag even if the error message says there is. < ?xml version="1.0" encoding="utf-8"?>< !DOCTYPE note [<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>]>< note>< to>Tove</to>< from>Jani</from>< heading>Reminder</heading>< body>Don't forget me this weekend!</body>< /note> XML Parsing Error: XML or text declaration not at start of entityLocation: file:///C:/xml/TMP4yhnhbl5pq.xmlLine Number 1, Column 9:<body ><?xml version="1.0" encoding="utf-8"?>--------^Can you help?. Edited October 8, 2012 by adriantreanor Quote Link to post Share on other sites
Ingolme 1,020 Posted October 8, 2012 Report Share Posted October 8, 2012 No, I cannot help any further if the parser is reading a different document than the one you're giving it. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.