Home  >  Article  >  Backend Development  >  XML file must have root tag (error) code solution to share

XML file must have root tag (error) code solution to share

黄舟
黄舟Original
2017-03-30 14:14:542678browse

The document used is as followsxml

<?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>

The problem is: there is no root tag! XML files can only have one root tag!
It will be ok to change the xml to the following, that is, add a Document tag, and put the two previous root tags SearchConstraints and StoPList under the Document tag, so that there is only one in the entire XML file root tag.

<?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>

The above is the detailed content of XML file must have root tag (error) code solution to share. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn