WordPress.org

Ready to get started?Download WordPress

Forums

Postie
[resolved] Parsing HTML table in filterPostie.php (5 posts)

  1. sniexx
    Member
    Posted 1 month ago #

    Hi,

    in filterPostie.php I have a function for parsing content, because all emails are a HTML table, which I have to parse before posting (some fields in table define category, title, author, ...). I tried with DOMDocument and simple dom but I just can't get it to work. Everytime I try to get text from a cell and write it in post field (post_category, post_content, post_title, ...), it writes empty string instead of writing text in post field. Can anybody help me?

    Regards,
    Sniexx

    https://wordpress.org/plugins/postie/

  2. Wayne Allen
    Member
    Plugin Author

    Posted 1 month ago #

    DOMDocument is for XML which HTML isn't necessarily.

    Postie loads SimpleHtmlDom (http://simplehtmldom.sourceforge.net/manual.htm) so I would use that instead.

  3. sniexx
    Member
    Posted 1 month ago #

    I'm trying with SimpleHtmlDom now and still can't get it to work. It looks like, when I load html (str_get_html), I can split it by 'tr' and 'td', but cannot search for text in a cell (I have to do this, so I can set correct post fields). I tried with 'plaintext', 'innertext', 'find' and all return empty string. Basically it's like this:
    I have a html table with few rows and each row has two tds. In first td is keyword and in second is value. What I have to do is search through first tds and when certain keyword is found (I need value from a cell to compare strings), the value is written in the corresponding post field.
    Do you have any idea how this can be done? I tried everything I could think of and without success.

  4. sniexx
    Member
    Posted 1 month ago #

    Update: I just managed to get it to work like I want :) The problem was in wrong comparison of strings.

  5. Wayne Allen
    Member
    Plugin Author

    Posted 1 month ago #

    Thanks for the update

Reply

You must log in to post.

About this Plugin

About this Topic