Tom Knowlton
asked on
parse portion of HTML - count of certain tag - C# RegEx code needed
This section of the HTML is of interest to me:
<select name="ctl00$ContentPlaceHo lder1$dlSt ore" id="ctl00_ContentPlaceHold er1_dlStor e" disabled="disabled" title="Store" style="text-align: left">
<option value="NULL">Select Campus...</option>
<option selected="selected" value="1">KSU ASHTABULA</option>
</select>
This will be surrounded by other HTML, but it is just this block of code that I want to extract and examine.
Within this block of code, above, I want to check for HOW MANY <option></option> pairings there are. If there is only one I want to do one thing. If there are more than one I want to do another thing.
So the logic would be:
(A) Isolate the portion of code above. Perhaps use the existence of "dlStore" in the id to identifiy the <select></select> block
(B) in this block of code we isolate in (A), count how many times there is an <option></option> pairing.
(C) do something based on the count.
Please provide tested working C# source code if you can.
I am using C# in a windows app to do this....I will favor a working C# .NET response over something more generic.
<select name="ctl00$ContentPlaceHo
<option value="NULL">Select Campus...</option>
<option selected="selected" value="1">KSU ASHTABULA</option>
</select>
This will be surrounded by other HTML, but it is just this block of code that I want to extract and examine.
Within this block of code, above, I want to check for HOW MANY <option></option> pairings there are. If there is only one I want to do one thing. If there are more than one I want to do another thing.
So the logic would be:
(A) Isolate the portion of code above. Perhaps use the existence of "dlStore" in the id to identifiy the <select></select> block
(B) in this block of code we isolate in (A), count how many times there is an <option></option> pairing.
(C) do something based on the count.
Please provide tested working C# source code if you can.
I am using C# in a windows app to do this....I will favor a working C# .NET response over something more generic.
I need to make a correction. Stand by.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Plugged in your code...seems to be ship shape and in Bristol fashion!
Thank you!
http://www.phrases.org.uk/meanings/ship-shape%20and%20Bristol%20fashion.html
Thank you!
http://www.phrases.org.uk/meanings/ship-shape%20and%20Bristol%20fashion.html
Heheh. Thanks! Glad to help = )
Open in new window