XML 文档不能包含多个根级元素
我有一个代码列表,其中出现错误“XML 文档不能包含多个根级别元素”
<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>
该错误发生在第一个
标记处。
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>
The error occurs at the first <Employee>
tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
XML 文档
必须
有一个且只有一个根元素。您必须添加根元素。例如,The XML document
must
have one and only one root element. You have to add root element. For instance,假设您想要打开文档,则可以将
XmlReader
的ConformanceLevel
设置为ConformanceLevel.Fragment
。Assuming what you want to do is open the document anyway, you can set the
ConformanceLevel
of theXmlReader
toConformanceLevel.Fragment
.您只需添加根元素即可解决您的错误......
You just have to add root element will resolve ur error.......
像这样
like this