Shahaf Nahmias
Shahaf Nahmias

Reputation: 81

XML - Document cannot contain multiple root elements

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" />

Upvotes: 1

Views: 1977

Answers (1)

kjhughes
kjhughes

Reputation: 111521

An XML documents must have a single root element. To solve your problem:

  • Remove all root elements except for one, or
  • Wrap all top-level elements in a single root element.

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.

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

Upvotes: 1

Related Questions