-6

I am using a PHP script to crawl data from HTML and struggling to parse the data within HTML <code> tag. For instance, in the following code, I would like to parse the content such as name, location, position and company name.

<code id="content" style="display:none;">
<!--{"required content":{"name:"John Smith", 
"location:"UK"}, "position:"Manager", "company:"IBM"}}-->
</code>

I would appreciate it if someone can point me in the right direction.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Lara
  • 29
  • 1
  • 5

2 Answers2

0

It seems you have json inside the <code> tag.
So first (after you get the inner html of the <code> tag) get rid of the comments ('<!--', '-->') and then use function json_decode()

lvil
  • 4,326
  • 9
  • 48
  • 76
-1

Take a look at PHP's strip_tags function: http://php.net/manual/en/function.strip-tags.php

This will at least remove the HTML entities from your string. You can also specify any HTML entities (tags, comments, etc.) that you want to keep, while removing everything else.

FastTrack
  • 8,810
  • 14
  • 57
  • 78