HTML and PHP Parser

S

Sergey Danilov

Hi all!

Anybody know html parser writing in java which take in account php tags
and could work with non-valid html or processing peace of html document
with php tags?

I found two library
Jericho HTML Parser
http://jerichohtml.sourceforge.net/
but It seems The author doesn't support it.

http://htmlparser.sourceforge.net/
and this very complicatied in use. I can't understand Do it support php
parsing and if it do, What way to use it ???

May be somebady give me good advice or something

Thanks in advance
 
M

Monique Y. Mudama

Hi all!

Anybody know html parser writing in java which take in account php
tags and could work with non-valid html or processing peace of html
document with php tags?

I found two library Jericho HTML Parser
http://jerichohtml.sourceforge.net/ but It seems The author doesn't
support it.

http://htmlparser.sourceforge.net/ and this very complicatied in
use. I can't understand Do it support php parsing and if it do, What
way to use it ???

May be somebady give me good advice or something

Thanks in advance

This request doesn't make sense to me. You would need not just an
HTML parser, but a PHP interpreter. You would need to run the PHP
script through the interpreter first, and only then could you try to
parse the HTML.

In other words, you'd be better off using exec() to run the script
file through a PHP interpreter, then taking the output of the PHP
interpreter and sending that to an HTML parser.

Am I wrong?
 
O

Oliver Wong

Monique Y. Mudama said:
This request doesn't make sense to me. You would need not just an
HTML parser, but a PHP interpreter. You would need to run the PHP
script through the interpreter first, and only then could you try to
parse the HTML.

In other words, you'd be better off using exec() to run the script
file through a PHP interpreter, then taking the output of the PHP
interpreter and sending that to an HTML parser.

Am I wrong?

The OP may, for example, be trying to write an IDE that is aware of both
HTML and PHP, and does syntax highlighting, autocompletion and other
Eclipse-like features. This IDE doesn't need to actually run the PHP code,
but merely to parse it, so it can display it in pretty colours. An IDE is
another place where it would be reasonable to want to handle "broken code",
since the programmer might be in the middle of typing a statement and
doesn't want a thousand errors to suddenly pop up after every new character
inserted.

- Oliver
 
M

Monique Y. Mudama

The OP may, for example, be trying to write an IDE that is aware
of both HTML and PHP, and does syntax highlighting,
autocompletion and other Eclipse-like features. This IDE doesn't
need to actually run the PHP code, but merely to parse it, so it
can display it in pretty colours. An IDE is another place where
it would be reasonable to want to handle "broken code", since
the programmer might be in the middle of typing a statement and
doesn't want a thousand errors to suddenly pop up after every
new character inserted.

Oh. My bad. I thought this was a question about displaying/rendering
HTML in java, not colorizing the code.
 
R

Roedy Green

An IDE is
another place where it would be reasonable to want to handle "broken code",
since the programmer might be in the middle of typing a statement and
doesn't want a thousand errors to suddenly pop up after every new character
inserted.

A parser to colourise code is a quite different animal than one to
parse it to run it. I have written a number of colorouriser parsers
that work on fragments. Mine work more like the way a human does,
looking at just the immediate context looking for clues. You can't
count on there being a matching declaration.

You can see the results all over my website. Happily, getting a colour
slightly off is not fatal.
 
S

Sergey Danilov

Yes.
I actually need for HTML and PHP parsing to make highlighting in my
editor.
Or the way to create this stuff.
 
O

Oliver Wong

Sergey Danilov said:
Yes.
I actually need for HTML and PHP parsing to make highlighting in my
editor.
Or the way to create this stuff.

If you're going to integrate this into your own code, you might want to
try the comp.compilers group. The regulars there probably have a treasure
chest of tools for dealing with problems like these.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top