tags:

views:

35

answers:

2

I have a div like this:

    <div class="widget-archive-monthly widget-archive widget"> 
    <h3 class="widget-header">Monthly <a href="http://myblog.com/blogs/my_name/archives.html"&gt;Archives&lt;/a&gt;&lt;/h3&gt; 
    <div class="widget-content"> 
        <ul> 
            <li><a href="http://myblog.com/blogs/my_name/2010/10/"&gt;October 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/09/"&gt;September 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/08/"&gt;August 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/07/"&gt;July 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/06/"&gt;June 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/05/"&gt;May 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/04/"&gt;April 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/03/"&gt;March 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/02/"&gt;February 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2010/01/"&gt;January 2010</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/12/"&gt;December 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/11/"&gt;November 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/10/"&gt;October 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/09/"&gt;September 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/08/"&gt;August 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/07/"&gt;July 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/06/"&gt;June 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/05/"&gt;May 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/04/"&gt;April 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/03/"&gt;March 2009</a></li> 
            <li><a href="http://myblog.com/blogs/my_name/2009/02/"&gt;February 2009</a></li> 
        </ul> 
    </div> 
</div> 

I'm trying to get the href values inside the widget-content div.

How would I target these links using xpath and ignore any other link on the page such as the one for "Archives" so that I end up just with these values:

        http://myblog.com/blogs/my_name/2010/10/
        http://myblog.com/blogs/my_name/2010/09/
        http://myblog.com/blogs/my_name/2010/08/
        http://myblog.com/blogs/my_name/2010/07/
        ... etc ...
A: 

relative answer = http://stackoverflow.com/questions/915338/xpath-find-link-url-by-link-text

"//a/@href"
brian brinley
+2  A: 
//div[@class="widget-content"]//a/@href

That should give you the href values of links that are ONLY inside the widget-content DIV.

Neeme Praks