<p>第一张图<img height="225" alt="aa" width="300" src="/upload/UserFiles/Blue hills.jpg" />第二张图测试<img height="225" width="300" alt="bb" src="/upload/UserFiles/Winter.jpg" />得到图测试</p>想得到结果
1    aa    upload/UserFiles/Blue hills.jpg
2    bb    upload/UserFiles/Winter.jpg

解决方案 »

  1.   

    var imgs=document.getElementsByTagName("img");
    for(var i=0;i<imgs.Length;i++)
    {
        imgs[i].src.substring(1, imgs[i].src.length);
        imgs[i].alt
    }
      

  2.   

    ajax,
    或者get、post到后台去
    或者把它们加个runat=server 
    或者用asp.net内置的scriptmanager脚本传递
    或者用服务端literal控件呈现,截取文本内容
    ...
      

  3.   

    如果你是想从字符串中解析出图片路径,可以考虑用正则            StreamReader reader = new StreamReader("c:\\temp\\1.txt",Encoding.Default);
                string source = reader.ReadToEnd();
                Regex reg = new Regex(@"(?is)(?<=<img[^>]*?src="")[^""]+(?="")");
                MatchCollection mc = reg.Matches(source);
                foreach (Match m in mc)
                {
                    MessageBox.Show(m.Value);
                }
      

  4.   


    <p>第一张图<img height="225" alt="aa" width="300" src="/upload/UserFiles/Blue hills.jpg" />第二张图测试<img height="225" width="300" alt="bb" src="/upload/UserFiles/Winter.jpg" />得到图测试</p>是从数据表中一个字段取出,不是页面内容
      

  5.   

    问题描述:
    用了网页编辑器fckedit输入了内容,保存到oracle table_doc(did,content),content字段类型是blob
    例如table_doc的内容是
    did    content
    1      <p>第一张图<img height="225" alt="aa" width="300" src="/upload/UserFiles/Blue  hills.jpg" />第二张图测试<img height="225" width="300" alt="bb" src="/upload/UserFiles/Winter.jpg" />得到图测试</p>想要的结果:
    想判读出content其中是否有图片,如果有就插入到表 table_attch中
    did  picid  descrip attch 
    1    1       aa      upload/UserFiles/Blue hills.jpg
    2    2       bb      upload/UserFiles/Winter.jpg     
      

  6.   

    非常感谢
    Regex reg = new Regex(@"(?is)(?<=<img[^>]*?src="")[^""]+(?="")");
                MatchCollection mc = reg.Matches(source);
                foreach (Match m in mc)
                {
                    MessageBox.Show(m.Value);
                }
    得到了上传路径,除了上传路径,还想得到alt中的内容,请问怎么办?