没有在asp.net中阅读html文件的内容

时间:2011-06-03 11:43:32

标签: asp.net html

我正在使用asp.net页面,我使用html编码.. 我正在使用XmlDocument读取一个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>

我没有超越我得到这个例外的地方.. 请帮帮我..

1 个答案:

答案 0 :(得分:1)

textarea1的开头标记中,末尾有两个双引号,这使得HTML无效。

更改

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

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