Click here to Skip to main content
11,636,260 members (75,176 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET GimmeCode+
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 6:52am
Edited 20-Feb-13 8:07am
Sandeep Mewara at 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 at 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
0 295
1 Sergey Alexandrovich Kryukov 275
2 OriginalGriff 233
3 Suvendu Shekhar Giri 225
4 stibee 215
0 OriginalGriff 8,941
1 Sergey Alexandrovich Kryukov 8,459
2 Mika Wendelius 6,849
3 F-ES Sitecore 2,364
4 Suvendu Shekhar Giri 2,320

Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2015
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