我正在尝试检查我的 html 是否也是格式正确的 xml,但我一直在 body 标签上收到此错误,
XML Parsing Error: junk after document element
Location: location/index.xml
Line Number 10, Column 1:
<body>
^
这是代码,
<!DOCTYPE html>
<head>
<meta charset="UTF-8" />
<title></title>
<link href="style/style.css" rel="stylesheet" type="text/css"/>
<link rel="icon" href="images/favicon.ico" />
</head>
<body>
<main>
<header>
</header>
<nav >
</nav>
<article>
</article>
</main>
<div class="push"></div>
<footer>
</footer>
</body>
</html>
为什么会出现此错误?
最佳答案
您忘记以 html
标记开始。 head
元素被当作根元素,并且在这个根元素之后有一个垃圾(body
)(只允许 child ,而不是根的 sibling )。
<!DOCTYPE html>
<html> <!-- here -->
<head>
<meta charset="UTF-8" />
<title></title>
<link href="style/style.css" rel="stylesheet" type="text/css"/>
<link rel="icon" href="images/favicon.ico" />
</head>
<body>
<main>
<header>
</header>
<nav >
</nav>
<article>
</article>
</main>
<div class="push"></div>
<footer>
</footer>
</body>
</html>
关于html - <body> 标签上的 "XML Parsing Error: junk after document element"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29533624/