in reply to Re^2: Traversing an HTMLTree with HTML:Element ->right
in thread Traversing an HTMLTree with HTML:Element ->right

Re: The "vcard" divs are children of the "secTitle" divs rather then siblings.

Oh how I wish that were true.
Here is a a snippet of the Husband portion of the page.
<div class="secTitle">HUSBAND</div> <div style='display:inline' class='vcard' id='hcard-Josiah-Leonard'> Name: <span class='fn n'> <a href="../F247/F247134.htm"> Josiah Leonard </a> </span> <span style='display:none'> <span class='x-gender'> Male </span> </span> <a href="#Note1"> Note </a> Born: Married: 2 Nov 1699 <span style='display: none'> <span class='x-marriage-date'> 1699-11-2 </span> </span> at Bridgewater, Plymouth, MA <span style='display: none'> <span class='x-marriage-location'> Bridgewater, Plymouth, MA </span> </span> Died: Abt 1745 <span style='display: none'> <span class='x-death-date'> 1745-1-1 </span> </span> at Bridgewater, Plymouth, MA <span style='display: none'> <span class='x-death-location'> Bridgewater, Plymouth, MA </span> </span> </div> Other Spouses: <a href="../F248/F248346.htm"> Abigail Washburn </a> <br> Father: <a href="../F247/F247134.htm"> John Leonard </a> Mother: <a href="../F247/F247134.htm"> Sarah Leonard </a> <br />
I think my problem is that I my iteration with ->right() assumes the ->content array of the parent node contains only references to HTML::Element objects. This assumption is wrong. The ->content array of an HTML::Element is a mix of text scalars and references. As your code (with the use of if ref() demonstrates). That this is not the case is demonstrated by this HTML snippet the test page
<span class='BogusClasNameForThisExample'> Father: <a href="../F247/F247134.htm"> John Leonard </a> Mother: <a href="../F247/F247134.htm"> Sarah Leonard </a> </span>
There are 4 elements in the ->content array of the span node:
I think I need to use the ->objectify_text() and \->deobjectify_text(). This should pack up the text as HTML::Elements so iterating with the ->right() function should then work.

I will let you know the results when I get home tonight.