HTML parsing?
Jun 10, 2014 at 12:26pm UTC
The title is a
little misguiding, I have the following sample HTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<div class ="directions" >
<h3>Directions</h3>
<div class ="directLeft" itemprop="recipeInstructions" >
<div id="msgDirections" style="display:none" ></div>
<ol>
<li><span class ="plaincharacterwrap break" >example</span></li>
</ol>
<a href="/recipe/easy-mac-n-cheese/kitchenview.aspx" >Kitchen-Friendly View</a>
</div>
<div id="divRecipeTimesContainer" class ="right-aside preptime fl-right" >
<ul id="ulReadyTime" >
<li id="liPrep" >
PREP
<span id="prepMinsSpan" ><em>2</em> mins</span>
<time id="timePrep" itemprop="prepTime" datetime="PT2M" ></time>
</li>
<li id="liCook" >
COOK
<span id="cookMinsSpan" ><em>13</em> mins</span>
<time id="timeCook" itemprop="cookTime" datetime="PT13M" ></time>
</li>
<li id="liTotal" class ="no-border" >
READY IN
<span id="totalMinsSpan" ><em class ="emp-orange" >15</em> mins</span>
<time id="timeTotal" itemprop="totalTime" datetime="PT15M" ></time>
</li>
</ul>
</div>
<div class ="clearfix ie7break" ></div>
</div>
I have the position of the
<div class ="directions" >
, but how can I get the HTML in it? There maybe more elements, if I try to
code.find("</div>" );
I may return the closing tag of a child of the div
directions
... A sample output I want of the previous input is:
<h3>Directions</h3>
<div class="directLeft" itemprop="recipeInstructions">
<div id="msgDirections" style="display:none"></div>
<ol>
<li><span class="plaincharacterwrap break">example</span></li>
</ol>
<a href="/recipe/easy-mac-n-cheese/kitchenview.aspx">Kitchen-Friendly View</a>
</div>
<div id="divRecipeTimesContainer" class="right-aside preptime fl-right">
<ul id="ulReadyTime">
<li id="liPrep">
PREP
<span id="prepMinsSpan"><em>2</em> mins</span>
<time id="timePrep" itemprop="prepTime" datetime="PT2M"></time>
</li>
<li id="liCook">
COOK
<span id="cookMinsSpan"><em>13</em> mins</span>
<time id="timeCook" itemprop="cookTime" datetime="PT13M"></time>
</li>
<li id="liTotal" class="no-border">
READY IN
<span id="totalMinsSpan"><em class="emp-orange">15</em> mins</span>
<time id="timeTotal" itemprop="totalTime" datetime="PT15M"></time>
</li>
</ul>
</div>
<div class="clearfix ie7break"></div>
Jun 10, 2014 at 1:21pm UTC
A similar problem. You've got a sequence of opening and closing parenthesis and want to find the matches
Example ()(( ()(()())) ()())
Note that they are 4 opening parenthesis (and so 4 closing parenthesis) between them
Jun 10, 2014 at 1:24pm UTC
@ne555 Ahhh... How dumb of me to miss that! And you've got me thinking!
Topic archived. No new replies allowed.