看到有朋友需要取得tag的值,很多人回复都是以正则来取。想了一下,它的字符串即是xml的节点。
只即需要转为xml之后,就可以很容易取得src的值:
string
str="<IMG height=\"372\" alt=\"aa\"
src=\"http://192.168.1.72/WebAdmin/images/image.jpg\" width=\"594\"
border=\"0\" />";
XmlDocument xDoc = new XmlDocument();
xDoc.Load(new System.IO.MemoryStream(System.Text.Encoding.GetEncoding ("UTF-8").GetBytes (str)));
XmlNodeList xNode = xDoc.SelectNodes("//IMG");
{
for (int i = 0; i < xNode.Count; i++)
{
Response.Write ( xNode[i].Attributes["src"].Value);
}
}
阅读(299) | 评论(0) | 转发(0) |