Home > Article > Backend Development > XML file must have root tag (error) code solution to share
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!