php - Simple HTML Dom - find text between divs -


I need to draw the text between divs ("third of all ...") - use of simple HTML domains Do PHP library

What I am thinking, I have tried! next_sibling () returns the comment, and next_sibling () -> gt; Next_sabilling () tags, ideally I will be at the end of the first comment and next

   Div class = "left" & gt; Bla-bla .. & lt; Div class = "float" & gt; Blah blah ... ... & lt; / Div & gt; & Lt ;! - End of div.float - & gt; & Lt; Br / & gt; Third of four demonstrations in the Morning Melinda series of the Society ... & lt; A href = 'index.php? Page = ticket & month = 20140201 '& gt; & Amp; Amp; Lt; & Amp; the lift; Go back to the full event list & lt; / A & gt; & Lt; / Div & gt; & Lt ;! - / end div.left - & gt;  

print it down and - comment tag

  // move a class float Accompanies the div. There is a comment between $ div_float = $ html- & gt; Search ("div.float"); $ Betweendivs = $ div_float [0] - & gt; Next_sabilling (); $ Real_content = $ betweendivs - & gt; External text; Echo $ real_content;  

My next step would be internal text of div.left and then all the devices inside it are being removed, but it seems like a big problem . Is anything easy, what can I do?

Use find ('text', $ index) All text To get the block, where $ index is the index of the desired text ...

So in this case, this is:

  hte Html-> Search ('text', 3); // Output: Third of the four features of the Society's Morning Melinda series ...  

You

Edit:

Here is a working code:

  $ input = '& lt; Div class = "left" & gt; Bla-bla .. & lt; Div class = "float" & gt; Blah blah ... ... & lt; / Div & gt; & Lt ;! - End of div.float - & gt; & Lt; Br / & gt; The third of four shows in the Morning Melinda series of the Society ... A href = "index.php? Page = tickets and months = 20140201" & gt; & Amp; Lt; & Amp; LT; Go back to the full event list & lt; / A & gt; & Lt; / Div & gt; & Lt ;! - / end div.left - & gt; '; // Create a DOM object $ html = new simple_html_dom (); Load HTML from // string $ html-> load ($ input); // $ Using the Index Reverse $ html- & gt; Search ('text', 3); Echo "& lt; hr & gt;"; // Or, this is the third element that $ $ end = text = $ html-> Search ('text') starts with; Echo $ text [count ($ text) -3]; // Clear DOM Object $ HTML- & gt; clear (); Not set ($ HTML); // Third part of four shows in the Morning Melinda series of Output Society ... Third of four demonstrations in the Morning Melinda series of the Society ...  


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -