0

i have this html

<p>some text.</p>
<p><pre>
<?php sample(); 
$var = 'aaa';
?>
</pre></p>
<p>describe</p>
<p>
<pre>
<html>...</html>
</pre>
</p>

you will notice that <pre> is in <p> that is wrong!

i want to remove all <p> that wrap <pre> not normal <p> paragraph.

how to use php correct this?


selenium IDE - how to storeText just the id within a link?

How can I create a variable that has the id from one of my records on the index page?

I can use xpath to get at the anchor I want with:

storeText
//table[@id='districts']//tr/td/a[text()='Fairview Union']
id_of_another_district

but that gets the link name. I want to id for that record, i.e. in the original source code I have:

<tr>
<td>
<a href="/districts/31">Fairview Union</a>
<span class='small'><a href="/users/change_district/31">(Select)</a></span>
</td>
<td></td>
<td></td>
<td></td>
<td class='rightalign'>01/09/2012</td>
<td></td>
<td><a href="/districts/31/overview" class="report_link right"></a></td>
<td><a href="/districts/31" class="deleteicon" data-confirm="Are you sure you want to delete all data and schedules for Fairview Union?" data-method="delete" rel="nofollow" title="Delete Fairview Union"><img alt="Delete" src="/assets/icons/delete-a77f3c3c125b0817085648f284c98938.png" /></a></td>
</tr>

and what I want to get and store in a variable in selenium is the record number 31

4

1 回答 1

1

我试过了,发现这段代码有效。

$content = 'as see in question';

$pattern = '#<p>(\\s*)(<pre.*/pre>)(\\s*)</p>#isU';
$content = preg_replace($pattern, '$2', $content);

echo $content;
于 2013-06-05T18:38:08.617 回答