我把一段HTML写进一个string里,如下:string str="<table border='0' cellspacing=0 cellpadding=0 width='100%' ID="CASE" style="display">";但是出错说缺少";"当我把"CASE"和"display"的双引号改成单引号时就没错了,但在不能改动HTML内容的情况下,这个问题怎么解决呢?

解决方案 »

  1.   

    string str="<table border='0' cellspacing=0 cellpadding=0 width='100%' ID=\"CASE\" style=\"display\">";
      

  2.   

    string str=@"<table border='0' cellspacing=0 cellpadding=0 width='100%' ID="CASE" style="display">";
      

  3.   

    双引号匹配的不对
    string str="<table border='0' cellspacing='0' cellpadding='0' width='100%' ID='CASE' style='display'>";
      

  4.   

    string str=@"<table border='0' cellspacing=0 cellpadding=0 width='100%' ID=""CASE"" style=""display"">";
      

  5.   

    string str="<table border='0' cellspacing=0 cellpadding=0 width='100%' ID=\"CASE\" style=\"display\">";
      

  6.   

    可是string是由以下代码自动获得的,怎么办呢?
    string str="";
    string fullpath = @"http://*******"; 
    HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(fullpath);
    HttpWebResponse webresp = (HttpWebResponse)webreq.GetResponse();
    StreamReader strm = new StreamReader(webresp.GetResponseStream(), Encoding.Default);
    str= strm.ReadToEnd();
      

  7.   

    string str=@"<table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"" ID=""CASE"" style=""display"">";
    因为你的字符串中有引号,匹配时出了问题。
      

  8.   

    完全正确
    string str="<table border='0' cellspacing=0 cellpadding=0 width='100%' ID=\"CASE\" style=\"display\">";
      

  9.   

    string str="<table border='0' cellspacing=0 cellpadding=0 width=100% ID=CASE style=display>";
      

  10.   

    TO wen98091(雪) 怎么替换呢?
      

  11.   

    string str="<table border='0' cellspacing=0 cellpadding=0 width=100% ID='CASE' style='display'>";