Click here to Skip to main content
13,248,562 members (83,675 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi ,
i want to extract all the categories and sub categories from this link. anyone please tell me how i can do so , please give me hint[^]

im practising webclient , PLEASE ONLY GIVE ME REGEX FOR IT. all categories and subcategories should be gathered

following is the code i have wrote so far :i want on ly regex to pass on it to gather all data

public ExtractHtml(String url)
            client = new WebClient();
            strm = client.OpenRead(url);
            StreamReader strrdr = new StreamReader(strm,Encoding.ASCII);
            code = strrdr.ReadToEnd();
        public List<string> Extract(String regex)
            lines = new List<string>();
            Regex rgx = new Regex(regex, RegexOptions.IgnoreCase);
            MatchCollection cl =  rgx.Matches(code);
            foreach (Match item in cl)
            return lines;

i want to extract text from this
<a id="ctl00_MC_TCRp_ctl00_TCNL" href="/Chapters/1/Desktop-Development.aspx">Desktop Development</a>

<a id="ctl00_MC_TCRp_ctl00_TSRp_ctl01_TSNL" href="/KB/buttons/">Button Controls</a>


<a id="ctl00_MC_TCRp_ctl00_TSRp_ctl02_TSNL" href="/KB/clipboard/">Clipboard</a>


<a id="ctl00_MC_TCRp_ctl00_TSRp_ctl03_TSNL" href="/KB/combobox/">Combo & List Boxes</a>


<a id="ctl00_MC_TCRp_ctl00_TSRp_ctl04_TSNL" href="/KB/dialog/">Dialogs and Windows</a>


<a id="ctl00_MC_TCRp_ctl00_TSRp_ctl05_TSNL" href="/KB/gadgets/">Desktop Gadgets</a>

Posted 20-Feb-13 7:52am
Updated 20-Feb-13 9:07am
Sandeep Mewara 20-Feb-13 13:00pm
You are practicing as you said, where is the effort made by you? All I see is "Give me regex for it" (that too in CAPS).
Shan Ali Khan 20-Feb-13 13:37pm
please have a look , i have updated it , i only need regex to pass to gather all data in list.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

How about you build your regex. Here[^] is a great online site that will allow you to build your regex through trial and error. Since you are demanding that we do it for you, this is all I'm going to give you, but it should be enough for you to move on in your quest for a solution. Cheers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100