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

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

黄舟
Release: 2017-03-30 14:14:54
Original
2708 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template