天天看點

XML檔案要有根标簽(Extra content at the end of the document in file 錯誤)

使用的xml文檔如下

[html]  view plain  copy  

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   <SearchConstraints>  
  3.     <Begin>glucose</Begin>  
  4.     <End>Ethanol</End>  
  5.     <Interface>name</Interface>  
  6.     <IntermediatesInclude number="0"></IntermediatesInclude>  
  7.     <IntermediatesExclude> number="0"></IntermediatesExclude>  
  8.     <Organisms type="all"></Organisms>  
  9.     <KShort>10</KShort>  
  10.   </SearchConstraints>  
  11.   <StoPList>  
  12.     <StoP>  
  13.       <Source id="glucose"></Source>  
  14.       <Target id="Ethanol"></Target>  
  15.       <RouteList>  
  16.       </RouteList>  
  17.     </StoP>  
  18.   </StoPList>  

問題所在:沒有加根标簽呀!XML檔案隻能有一個根标簽!

把xml改成下面這樣就ok了,也就是加一個Document标簽,将先前的兩個根标簽SearchConstraints和StoPList都放到Document标簽的下面,進而整個XML檔案隻有一個根标簽。

[html]  view plain  copy  

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <Document>  
  3.   <SearchConstraints>  
  4.     <Begin>glucose</Begin>  
  5.     <End>Ethanol</End>  
  6.     <Interface>name</Interface>  
  7.     <IntermediatesInclude number="0"></IntermediatesInclude>  
  8.     <IntermediatesExclude> number="0"></IntermediatesExclude>  
  9.     <Organisms type="all"></Organisms>  
  10.     <KShort>10</KShort>  
  11.   </SearchConstraints>  
  12.   <StoPList>  
  13.     <StoP>  
  14.       <Source id="glucose"></Source>  
  15.       <Target id="Ethanol"></Target>  
  16.       <RouteList>  
  17.       </RouteList>  
  18.     </StoP>  
  19.   </StoPList>  
  20. </Document>