开发者

Retrieve value from attribute in HTML tag in asp.NET

开发者 https://www.devze.com 2023-02-09 17:52 出处:网络
I have a large string containing a custom HTML tag (xxx). The tag also has two attributes. How would I retrieve the value of the two attributes and then place the tag and its content with a new strin

I have a large string containing a custom HTML tag (xxx). The tag also has two attributes.

How would I retrieve the value of the two attributes and then place the tag and its content with a new string derived from th开发者_运维问答ose two attributes?

Thanks for your time.


Where do you want to retrieve it? In the code behind?

If your tag is runat="server", you can do:

mytag.Attributes["nameofmyattribute"]


If its in string then you should consider using HTML Agility Pack. However it may be overkill so show us some sample string... maybe only some RegEx can do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消