The element type “META” must be terminated by the matching end-tag “</META>”

∥☆過路亽.° 提交于 2019-12-22 04:09:36

问题


I've got the following error sometimes when I'm try to parse a XML file with Java (within GAE server):

Parse: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 3; The element type "META" must be terminated by the matching end-tag "</META>".

Yet it is not happening all the time, sometimes It's works alright. The program parsing xml files and I've no problem with them.

This is the XML file I'm trying to parse: http://www.fulhamchronicle.co.uk/london-chelsea-fc/rss.xml

Any help will be appreciated. Thanks.


Update:

Thanks for the answer. I changed my code to a different parser and the good news the file is now parsing correctly. The bad it now moved for another feed same problem, same line despite completely different feed and it worked perfectly before. Could anyone think of why it's happening?


回答1:


That looks like it is a live document; i.e. one that changes fairly frequently. There is also no sign of a <meta> tag in it.

I can think of two explanations for what is happening:

  • Sometimes the document is being generated or created incorrectly.

  • Sometimes you are getting an HTML error page instead of the document you are expecting, and the XML parser can't cope with a <meta> tag in the HTML's <head>. That is because the <meta> tag in (valid) HTML does not need to have a matching / closing </meta> tag. (And for at least some versions of HTML, it is not allowed to have a closing tag.)

To track this down, you are going to have to capture the precise input that is causing the parse to fail.




回答2:


You can try <meta/> instead of <meta>.




回答3:


just apply (/) after every line with meta

<meta name=" " content=" " />

when using ,

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

and really it works




回答4:


It is not XML but HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">

The XML parser will not parse it.

I see the file hasn't any content and it doesn't look like valid RSS file. May be any server-side error occurs.




回答5:


can you use this tag

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


来源:https://stackoverflow.com/questions/16526248/the-element-type-meta-must-be-terminated-by-the-matching-end-tag-meta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!