2011-06-03 35 views
0

我正在使用asp.net頁面,我使用html編碼.. 我正在閱讀使用XmlDocument的html文件,但問題是,它給出了一個例外:在asp.net中沒有閱讀html文件的內容

Name cannot begin with the '"' character, hexadecimal value 0x22 

我使用XmlDocument的是:

string dir = HttpContext.Current.Request.PhysicalApplicationPath; 
      string htmfile = dir + "webform.html"; 
      XmlDocument xmlDoc = new XmlDocument(); 
      xmlDoc.Load(htmfile); 
      XmlNodeList list = xmlDoc.SelectNodes("html/body/form/div/table/tbody/tr/td/img"); 
      list.Item(0).Attributes[1].Value = thumbpath + Session["WorkingImage"].ToString(); 
      xmlDoc.Save("webform.html"); 

和我的html文件是:

<html> 
<head> 
    <title>Untitled Page</title> 

</head> 
<body> 
    <form id="form1" runat="server" style="margin:10px 100px 20px 350px; border:1px solid; width:500px; height:800px;"> 
    <div> 
    <table width="490px" style=" border:1px solid; margin:4px 4px 4px 4px; height:150px;"> 
     <tbody> 
     <tr> 
      <td style="width:480px; height:145px; margin:4px 4px 4px 4px;"> 
       <img src="images1.jpg" width="480px" height="145px"/> 
      </td> 
     </tr> 
     </tbody>  
    </table> 
    </div> 
    <div> 
     <table width="192px" style=" margin-left:4px; margin-top:10px; margin-right:10px ; padding:4px 4px"> 
     <tbody> 
      <tr> 
       <td> 


        <div id="topdiv" style="color:Blue; width:485px; height:130px;" > 
        <input type="image" id="Image1" style="margin: 9px 4px 4px 4px; width:142px; height:117px;" 
         src="images.jpg" onmouseover="mousein(this);" onmouseout="mouseout(this);"/>     
         <textarea id="txtarea1" value="sample text" disabled="true" style=" width:300px; height:117px; 
          margin:0px 0px 4px 4px; color:Maroon;" onmouseover="mousein(this);" 
          onmouseout="outmouse();""> 
          first div tag 
         </textarea> 
        </div> 
       </td>  
      </tr> 
     </tbody> 
    </table> 
    </div> 
    <table> 
     <tbody> 
      <tr> 
       <td>  

         <textarea id="txtarea2" value="sample text" disabled="true" style=" width:300px; height:117px; 
          margin:5px 0px 4px 4px; color:Maroon" onmouseover="mousein(this);" > 
         Second Div Tag 
         </textarea>&nbsp;&nbsp;&nbsp; 
         <input type="image" id="img" 
         style="margin: 8px 4px 4px 4px; width:142px; height:117px;" src="images2.jpg" 
         onmouseover="mousein(this);" onmouseout="mouseout(this);" /> 

       </td> 
      </tr> 
     </tbody>  
    </table>  
    </form> 
</body> 
</html> 

我不是GE從這裏我得到這個例外的點.. 請幫我..

+1

有在第一textarea的開始標記的最後兩個雙引號。所以你的HTML無效。也許這是導致錯誤。 – davehauser 2011-06-03 11:47:52

+0

我認爲你是正確的@Dave – 2011-06-03 11:51:10

+0

我會做出答案,所以你可以接受它:-) – davehauser 2011-06-03 12:14:10

回答

1

textarea1的開始標記最後有兩個雙引號,這使得HTML無效。

變化

<textarea id="txtarea1" ... onmouseout="outmouse();""> 

<textarea id="txtarea1" ... onmouseout="outmouse();">