Forum Moderators: coopster

Message Too Old, No Replies

getting the text between the div tag with <script > tag

         

freshfromseo

2:47 am on Jan 28, 2008 (gmt 0)

10+ Year Member



can anyone help me about this code below? i want to get the text between the div tag...

<!-- Main Story content START -->
<div class="leftColStory">
<script type="text/javascript">

document.write("<div class=\"findBox\" id=\"resultRelatedContainer39169779\">" +
"<span id=\"resultRelated39169779\"><a href=\"javascript: om_ctrack(this, 'ra-open', 'ra - story - open'); article_loadSimDocs(39169779, '', 'http://management.example.com/careers/0,39024671,39169779,00.htm')\">" +
"<img src=\"/i/s4/gl/ico/related-articles.gif\" width=\"13\" height=\"14\" alt=\"\" title=\"\" border=0/>Show related <br />" +
"<span class=\"alignSecondLine\">articles</span></a></span><div id=\"resultRelatedContent39169779\" style=\"display: none; clear: both\"></div></div>");

</script>

<p>...</p>
<!-- Main Quote at Top START -->
<div class="leftColStoryQuote">
<div class="leftColStoryQuoteImg"><img src="/i/s4/gl/quote-left-dark.gif" width="21" height="18" border="0" alt="" /></div>
<div class="leftColStoryQuoteText">text text text<img src="/i/s4/gl/quote-right-dark.gif" width="21" height="18" border="0" alt="" /></div>
<br clear="all" />
</div>
<!-- Main Quote at Top END -->
<p>text text text</p>

</div>
<!-- Main Story content END -->
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

im using this
preg_match('/<div class="leftColStory">(?>(?:[^<]++¦<(?!\/?div\b[^>]*>))+¦(?R))*<\/div>/is',$html,$body);
preg_match('/<div class="leftColStoryQuoteText">(?>(?:[^<]++¦<(?!\/?div\b[^>]*>))+¦(?R))*<\/div>/is',$html,$body1);

$text = $body[0] . "<p" . $body1[0];

echo $text;

but it doesnt work, i want to display the text between <div class="leftColStory"> and <div class="leftColStoryQuoteText">...please help me..i hope somebody could give me the right code for that...thank you very much

[edited by: eelixduppy at 2:49 am (utc) on Jan. 28, 2008]

[edited by: coopster at 12:40 am (utc) on Oct. 30, 2009]
[edit reason] please use example.com [/edit]

vincevincevince

1:53 am on Jan 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Simplify your expressions until they work, then complicate them again. Escape everything but a-z and 0-9.

preg_match('/\<div\ class\=\"leftColStory\"\>(.*?)\<\/div\>/ism',$html,$body);

That should get something... then complicate it until you get exactly what you want. Test the expression with each new part you add.

And please remember to escape everything other than 0-9 and a-z.

freshfromseo

8:25 am on Jan 30, 2008 (gmt 0)

10+ Year Member



ok, tnx vince....i can display the text now...tnx