由于我们要把输入的控件名称取出,存入数据库中,那个我们就要获取html代码中指定标签的指定属性值。
/// <summary>
/// 获取html指定标签的指定属性值
/// </summary>
/// <param name="strHtml">html字符串</param>
/// <param name="strTagName">标签名</param>
/// <param name="strAttributeName">属性名</param>
/// <returns></returns>
public static string[] GetAttribute(string strHtml, string strTagName, string strAttributeName)
{
List<string> lstAttribute = new List<string>();
string strPattern = string.Format("<\s*{0}\s+.*?(({1}\s*=\s*"(?<attr>[^"]+)")|({1}\s*=\s*'(?<attr>[^']+)')|({1}\s*=\s*(?<attr>[^\s]+)\s*))[^>]*>", strTagName, strAttributeName);
MatchCollection matchs = Regex.Matches(strHtml, strPattern, RegexOptions.IgnoreCase);
foreach (Match m in matchs)
{
lstAttribute.Add(m.Groups["attr"].Value);
}
return lstAttribute.ToArray();
}
转载于:https://www.cnblogs.com/EntityFramework/archive/2013/06/07/3124062.html
最后
以上就是简单吐司最近收集整理的关于OA系统中工作流和表单设计详谈系列--3 获取html指定标签的指定属性值的全部内容,更多相关OA系统中工作流和表单设计详谈系列--3内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复