I see lots of php libraries that can parse html. A nice example is QueryPath which mimics the Jquery Api.
However, I am looking to analyse phtml
. So, not only would the library be good at analysing the DOM, but also be good at analysing the php processing instructions. e.g The Php Document Object Model or PDOM.
A document like this:
<?php
require 'NameFinder.php';
$title = 'Wave Hello';
$name = getName();
?><html>
<head>
<title><?php echo $title ?></title>
</head>
<body>
<h1>Hello <?php echo $name ?></h1>
<p>Blah Blah Blah</p>
</body>
I'd like to be able to use this kind of php library to read things like:
- the inner html of a DOM node, found by xpath or css selector.
as well possibly offering things like:
- a list of php functions/method invoked in the script
- values of php variables
- pages required by that page
- a list of php variables used before line 5
- a list of php variables used before the 1st para of the body element
I could spend some time peicing something together, borrowing code from things like phpdocumentor and Zend Framework Reflection, using the in-built DOM Api, introspection and string manipulation, etc.
But, if there is some kind of *phtmlQuery" library out there that can do these kinds of things then it will handy.