使用的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檔案要有根標籤(錯誤)的程式碼解決分享的詳細內容。更多資訊請關注PHP中文網其他相關文章!