XML文档不能包含多个根级别元素 [英] XML document cannot contain multiple root level elements

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

问题描述

我有一个错误代码清单,"XML文档不能包含多个根级元素".

I have a list of codes to which i have an error "XML document cannot contain multiple root level elements"

<Employee>
  <Name ID= "JanRich">Janice Richardson</Name>
  <Role>Finance Supervisor</Role>
  <Department>Sales</Department>
  <CPF_Number>370-16-3631</CPF_Number>
  <Marital_Status>Single</Marital_Status>
  <Salary>$4,500</Salary>
</Employee>
<Employee>
  <Name ID= 'AlanWu'>Alan Wu</Name>
  <Role></Role>
  <Department>Research</Department>
  <CPF_Number>
    385-22-3311
  </CPF_Number>
  <Marital_status>Married</Marital_status>
  <Salary>$52,800</Salary>
</Employee>

该错误发生在第一个< Employee> 标记处.

The error occurs at the first <Employee> tag.

推荐答案

XML文档必须具有一个且只有一个根元素.您必须添加根元素.例如,

The XML document must have one and only one root element. You have to add root element. For instance,

<?xml version="1.0" encoding="utf-8" ?> 
<Employees>
    <Employee>
       .....
    </Employee>
    <Employee>
       ....
    </Employee>
</Employees>

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

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