HTML and PHP Parser

Discussion in 'Java' started by Sergey Danilov, Oct 25, 2005.

  1. 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
     
    Sergey Danilov, Oct 25, 2005
    #1
    1. Advertising

  2. Sergey Danilov

    Roedy Green Guest

    On 24 Oct 2005 23:17:24 -0700, "Sergey Danilov"
    <> wrote, quoted or indirectly quoted someone
    who said :

    >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?


    for some possibilities see
    http://mindprod.com/jgloss/htmlrendering.html

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Oct 25, 2005
    #2
    1. Advertising

  3. On 2005-10-25, Sergey Danilov penned:
    > 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?

    --
    monique

    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Monique Y. Mudama, Oct 25, 2005
    #3
  4. Sergey Danilov

    Oliver Wong Guest

    "Monique Y. Mudama" <> wrote in message
    news:...
    > On 2005-10-25, Sergey Danilov penned:
    >> 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?


    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
     
    Oliver Wong, Oct 25, 2005
    #4
  5. On 2005-10-25, Oliver Wong penned:
    >
    > 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.

    --
    monique

    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Monique Y. Mudama, Oct 25, 2005
    #5
  6. Sergey Danilov

    Roedy Green Guest

    On Tue, 25 Oct 2005 20:49:09 GMT, "Oliver Wong" <>
    wrote, quoted or indirectly quoted someone who said :

    >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.


    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Oct 26, 2005
    #6
  7. Yes.
    I actually need for HTML and PHP parsing to make highlighting in my
    editor.
    Or the way to create this stuff.
     
    Sergey Danilov, Oct 26, 2005
    #7
  8. Sergey Danilov

    Oliver Wong Guest

    "Sergey Danilov" <> wrote in message
    news:...
    > 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
     
    Oliver Wong, Oct 26, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ZOCOR

    XML Parser VS HTML Parser

    ZOCOR, Oct 3, 2004, in forum: Java
    Replies:
    11
    Views:
    847
    Paul King
    Oct 5, 2004
  2. Ted Zeng
    Replies:
    4
    Views:
    571
    Tim Arnold
    Oct 3, 2006
  3. Rajive Narain
    Replies:
    0
    Views:
    2,091
    Rajive Narain
    Sep 18, 2009
  4. Zach Dennis

    HTML-Parser / SGML-Parser

    Zach Dennis, Oct 1, 2003, in forum: Ruby
    Replies:
    5
    Views:
    455
    Bernard Delmée
    Oct 1, 2003
  5. __
    Replies:
    1
    Views:
    132
    Gregor Kofler
    Oct 2, 2007
Loading...

Share This Page