SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DOMDocument script tag clossing issue

    Hey guys,

    I am using DOMDocument to grab HTML and alter it then spit it back out. For HTML pages that have script tags with a nested "</" in it that is not a "</script>", the script tag will be ended prematurely. Are there ways to get around this when using DOMDocument?

    I tried searching far and wide and nobody seems to have found a solution.

    For example
    Code:
    <script>document.write('<p>hello</p>');</script>
    will be outputted as:
    Code:
    <script>document.write('<p>hello</script>
    thus ending prematurely due to the "</" in the "</p>" ending tag

  2. #2
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So I used the HTML5 parser now instead of DOMDocument, and it seems to be working for the script tag issues. But it doesn't load every page. Why does it not load some pages? Does it expect perfect HTML markup or something? How can I get around that?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •