string resoureHtml = "<ul><li><img src=‘123‘/></li><li><img src=‘456‘/></li></ul>"; Lexer lexer = new Lexer(resoureHtml); Parser parser = new Parser(lexer); //获取UL标签 string tagName = "ul"; NodeFilter filter = new TagNameFilter(tagName); StringBuilder sb = new StringBuilder(); NodeList nodeList = parser.Parse(filter); var lis = nodeList[0].Children; for (int i = 0; i < lis.Count; i++) { var li = lis[i]; sb.Append("<li>"); var img = li.Children; for (int j = 0; j < img.Count; j++) { var tag = (ImageTag)img[0]; var src= tag.GetAttribute("src"); sb.AppendFormat("<img src=\"{0}\" data-value=\"{1}\"/>", src + "ti",src+"ti"); } sb.Append("</li>"); } var aaa = sb.ToString();