Grabbing un-nested ul elements.

7 views
Skip to first unread message

Fred Diego

unread,
Mar 25, 2014, 1:12:22 AM3/25/14
to nokogi...@googlegroups.com
I am using Nokogiri to grab a list of College Papers from this wiki list and store them and array in the following fashion:

 STATE | UNIVERSITY | PAPER | PAPER_SITE | CONTACTS/EDITOR(S)

I can't figure out how to grab the ul and its li elements that immediately follow and h2 with a specific id. The source is as follows:

<h2><span class="mw-headline" id="Alabama"><a href="/wiki/Alabama" title="Alabama">Alabama</a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=List_of_student_newspapers_in_the_United_States&amp;action=edit&amp;section=1" title="Edit section: Alabama">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ul>
<li><a href="/wiki/Auburn_Universitytitle="Auburn University">Auburn University</a> – <i><a href="/wiki/The_Auburn_Plainsmantitle="The Auburn Plainsman">The Auburn Plainsman</a></i></li>
<li><a href="/wiki/Troy_Universitytitle="Troy University">Troy University</a> – <i><a rel="nofollowclass="external texthref="http://trop.troy.edu">Tropolitan</a></i></li>
</ul> 

I would like to be able to iterate through an array of state names, find the relevant h2 tag and grab the li elements from the ul that is immediately under it. 

How would one go about doing so?

thanks for the help


Mike Dalessio

unread,
Apr 3, 2014, 11:03:35 AM4/3/14
to nokogiri-talk
Hi Fred,

Thanks for asking this question! What have you tried so far? Generally list members will help out if you show your work.

Best of luck,
-mike



--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
To post to this group, send email to nokogi...@googlegroups.com.
Visit this group at http://groups.google.com/group/nokogiri-talk.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages