1
<div id="lyrics">
  <img />
  <span id="line_31" class="line line-s">En medio de este tropico mortal</span
  <br>
  <span id="line_32" class="line line-s">Roots and creation, come again!</span>
  <br> 
  <span id="line_33" class="line line-s">So mi guardian, mi guardian mi lift up di plan</span>
  <span id="line_34" class="line line-s">Now everybody a go' do dis one</span>
  <span id="line_35" class="line line-s">Like in down di Caribbean</span>
  <span id="line_36" class="line line-s">San Andrés, Providence Island</span>
  <br>
</div>

Here I have a div, inside div there is multiple span and br tag between span. I want to scrape the span text and br tag as it is. so how can i scrape with php simple dom parser.

thanks for any help.

1 Answer 1

2

Let's say the html file you have above is called "index.html".

$html = file_get_html("index.html");
$element = $html->find('div#lyrics');
$result = $element->innertext;

You want to consult the manual: http://simplehtmldom.sourceforge.net/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.