-2

I have a PHP script that gets the HTML from a website with curl. The probleem is i want to get only a specific part of the HTML for example: The HTML code

<HTML>
<head></head>
<body>
  <div>
    <tabel>
      <TR>
        <td> text </td>
      </TR>
      <TR>
        <td> 
          <tabel>
            ....
          </tabel>
      </TR>
    </tabel>
  </div>
</body>
</HTML>

Now i want a string text and a string .... But i can`t use id or class

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Rick Clephas
  • 26
  • 1
  • 5
  • and how you going to know which `text` is that `text` you want? best approach is to use DOM or xpath but if you can't use id or class then i suggest you try harder. or use regexp (lame but sometimes last resort) – Marcin Orlowski Aug 21 '13 at 21:32
  • 4
    [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php/3577662#3577662) –  Aug 21 '13 at 21:32
  • So what approach are you taking to do this? Where are you running into trouble? – Mike Brant Aug 21 '13 at 21:32
  • **table** and not `tabel` ahem (You'll hit a brick wall with that code, *literally*) – Funk Forty Niner Aug 21 '13 at 21:33
  • Can`t i specifi a path or something like div/tabel/TR/td – Rick Clephas Aug 21 '13 at 21:33
  • This might be useful http://www.jonasjohn.de/snippets/php/get-between.htm – Iesus Sonesson Aug 21 '13 at 21:35
  • @RickC Did you bother to read the first answer there?? –  Aug 21 '13 at 21:36
  • @MarcinOrlowski the test are always in the same place in the code the only diference is ons time the text is text land the ither time Hello or something else – Rick Clephas Aug 21 '13 at 21:43

1 Answers1

1

You need to parse DOM. You can either use php DOM extension, or any library like Simple HTML DOM Parser etc.

Javid
  • 2,755
  • 2
  • 33
  • 60