XML文件要有根标签(Extra content at the end of the document in file 错误)

前端之家收集整理的这篇文章主要介绍了XML文件要有根标签(Extra content at the end of the document in file 错误)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转自:http://bioinfo.ustc.edu.cn/seagven/?p=769


今天在使用PHP解析XML时出现错误

DOMDocument::load() [domdocument.load]: Extra content at the end of the document in file *****

使用的xml文档如下

<?xml version="1.0" encoding="UTF-8"?>
  <SearchConstraints>
    <Begin>glucose</Begin>
    <End>Ethanol</End>
    <Interface>name</Interface>
    <IntermediatesInclude number="0"></IntermediatesInclude>
    <IntermediatesExclude> number="0"></IntermediatesExclude>
    <Organisms type="all"></Organisms>
    <KShort>10</KShort>
  </SearchConstraints>
  <StoPList>
    <StoP>
      <Source id="glucose"></Source>
      <Target id="Ethanol"></Target>
      <RouteList>
      </RouteList>
    </StoP>
  </StoPList>

问题所在: 没有加根标签呀! XML文件只能有一个根标签
把xml改成下面这样就ok了,也就是 加一个Document标签,将先前的两个根标签SearchConstraints和StoPList都放到Document标签的下面,从而整个XML文件只有一个根标签

<?xml version="1.0" encoding="UTF-8"?>
<Document>
  <SearchConstraints>
    <Begin>glucose</Begin>
    <End>Ethanol</End>
    <Interface>name</Interface>
    <IntermediatesInclude number="0"></IntermediatesInclude>
    <IntermediatesExclude> number="0"></IntermediatesExclude>
    <Organisms type="all"></Organisms>
    <KShort>10</KShort>
  </SearchConstraints>
  <StoPList>
    <StoP>
      <Source id="glucose"></Source>
      <Target id="Ethanol"></Target>
      <RouteList>
      </RouteList>
    </StoP>
  </StoPList>
</Document>

猜你在找的XML相关文章