Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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
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


XML
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
Updated 20-Feb-13 8:07am
v4
Comments
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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900