I use C# and need to parse an HTML to read the attributes into key value pairs.
e.g given the following HTML snippet
<DIV myAttribute style="BORDER-BOTTOM: medium none; BACKGROUND-COLOR: transparent; BORDER-TOP: medium none" id=my_ID anotherAttribNamedDIV class="someclass">
Please note that the attributes can be
1. key="value" pairs e.g class="someclass"
2. key=value pairs e.g id=my_ID
(no quotes for values)
3. plain attributes e.g myAttribute
, which doesn't have a "value"
I need to store them into a dictionary with key value pairs as follows
key=myAttribute value=""
key=style value="BORDER-BOTTOM: medium none; BACKGROUND-COLOR: transparent; BORDER-TOP: medium none"
key=id value="my_ID"
key=anotherAttribNamedDIV value=""
key=class value="someclass"
I am looking for regular expressions to do this.
You can do this with the HtmlAgilityPack