Friday 19 April 2019

Parse HTML Table - PHP




I have an HTML table that I would like to parse in PHP to store into a MySQL Database. The HTML looks like this:




DATELOCATIONNAME




I would like to create a PHP function that returns in an array, the fields in capital letters. Does anyone know any php libraries that can do this, or should I be using a different language, as this may be complex. I don't know exactly how to do this with many tables on the page, but I am trying to parse the VEX events on RobotEvents. The table that I want to parse starts at line 465.


Answer



As you're prepared to look beyond PHP, Nokogiri (Ruby) and Beautiful Soup (Python) are well-established libraries that parse HTML very well.



That doesn't imply that there are no suitable PHP libraries.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...