Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
http://www.codeproject.com/script/Content/SiteMap.aspx[^]
 
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)
            {
                lines.Add(item.Value);
            }
            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>
 

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

</li>

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

</li>

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

</li>

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

</li>

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

</li>
Posted 20-Feb-13 7:52am
Edited 20-Feb-13 9:07am
v4
Comments
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
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 504
1 Maciej Los 349
2 Kornfeld Eliyahu Peter 325
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
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