How do you parse an HTML string for image tags to get at the SRC information?

前端 未结 4 1818
清酒与你
清酒与你 2020-12-08 20:26

Currently I use .Net WebBrowser.Document.Images() to do this. It requires the Webrowser to load the document. It\'s messy and takes up resources. <

4条回答
  •  离开以前
    2020-12-08 20:39

    If it's valid xhtml, you could do this:

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(html);
    XmlNodeList results = doc.SelectNodes("//img/@src");
    

提交回复
热议问题