XML - 文档不能包含多个根元素 [英] XML - Document cannot contain multiple root elements

查看:47
本文介绍了XML - 文档不能包含多个根元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图与 git 合并,但它显然导致了 XML 文件的问题,使项目不可用.我对 XML 一无所知.这是我的文件的摘录:

I was trying to merge with git, but it apparently caused a problem with the XML file making a project unavailable. I know nothing about XML. Here is an excerpt of my file:

  <ItemGroup>
    <Content Include="MetroFramework.txt" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

推荐答案

一个 XML 文档必须有一个根元素.要解决您的问题:

  • 删除除一个之外的所有根元素,或
  • 将所有顶级元素包装在一个根元素中.

除非您确保 XML 文档具有单个根元素,否则您的文件不会格式良好(实际上也不会是 XML).此外,如果您的文档打算遵循架构,请确保根元素及其内容(递归)根据架构(XSD、DTD 等)有效.有关这方面的更多信息,请参阅格式正确与无效 XML.

Until you ensure that your XML document has a single root element, your file will not be well-formed (and will not actually be XML). Also, if your document is intended to follow a schema, make sure the root element and its contents (recursively) is valid according to the schema (XSD, DTD, etc). For more on this, see well-formed vs invalid XML.

正如 Alex K 指出的,您的XML 文档看起来像是一个 MSBuild 项目文件.

As Alex K points out, your XML document looks like it's intended to be a MSBuild Project file.

这篇关于XML - 文档不能包含多个根元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆