The element type “META” must be terminated by the

2019-04-24 01:48发布

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?

4条回答
萌系小妹纸
2楼-- · 2019-04-24 02:04

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

查看更多
Viruses.
3楼-- · 2019-04-24 02:08

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.

查看更多
Ridiculous、
4楼-- · 2019-04-24 02:12

can you use this tag

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
查看更多
家丑人穷心不美
5楼-- · 2019-04-24 02:13

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.

查看更多
登录 后发表回答