adriantreanor Posted October 8, 2012 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 Link to comment Share on other sites More sharing options...
Ingolme Posted October 8, 2012 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? Link to comment Share on other sites More sharing options...
adriantreanor Posted October 8, 2012 Author 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)]>-----------------------------^ Link to comment Share on other sites More sharing options...
Ingolme Posted October 8, 2012 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. Link to comment Share on other sites More sharing options...
adriantreanor Posted October 8, 2012 Author 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"?>--------^ Link to comment Share on other sites More sharing options...
Ingolme Posted October 8, 2012 Share Posted October 8, 2012 You still have a <body> tag before the <?xml ?> declaration. Link to comment Share on other sites More sharing options...
adriantreanor Posted October 8, 2012 Author 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 Link to comment Share on other sites More sharing options...
Ingolme Posted October 8, 2012 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now