Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jamie Mansel 10 posts 30 karma points
    Apr 08, 2013 @ 13:45
    Jamie Mansel
    0

    'br' start tag does not match end tag of 'p'

    Hello,

    When using the PDFRazorExample on certain pages (not all), I get the following error:

    An exception occured parsing your content as XML: The 'br' start tag on line 35 position 245 does not match the end tag of 'p'. Line 36, position 405.

    I have tried adding in a case for 'br' in the master page, and also the Pdf.cshtml, but to no avail:

    case "br":
              <fo:block>
                @ParseRichText(node.ChildNodes)
              </fo:block>
              break;

    @helper Break(XmlNode node){
              <fo:block>
                @ParseRichText(node.ChildNodes)
              </fo:block>
    }
    ...
    case "br":
                    @Break(node)
                    break;

     

    The page itself has a few rich text areas.

    Any ideas? Thanks,

    Jamie

  • Jamie Mansel 10 posts 30 karma points
    Apr 08, 2013 @ 14:01
    Jamie Mansel
    0

    Little update:

    After looking at the HMTL of these pages, I've noticed there are some malformed 'br' tags, i.e. <br>, without the closing slash. I've looked at the HTML for these rich text areas and there isn't any <br> tags inside, so they must be getting inserted between between the RTE and being rendered. Is there a way to handle these tags or will I have to investigate how these are being added (and remove them/form them correctly).

    I am also receiving a different error on other pages:

    The 'p' start tag on line 18 position 2 does not match the end tag of 'xml'.

    The only suspicious HTML I've noticed on these pages are empty 'p' tags, i.e. <p>  </p>. Again these aren't visible in the RTE HTML code, just on the page itself.

    Regards,

    Jamie

  • Jamie Mansel 10 posts 30 karma points
    Apr 15, 2013 @ 10:03
    Jamie Mansel
    0

    Hey, any feedback on this issue?

    Getting a little urgent now.

    Thanks,

    Jamie

  • Jamie Mansel 10 posts 30 karma points
    Apr 19, 2013 @ 14:23
    Jamie Mansel
    0

    Hello,

    I managed to find a solution:

    Whilst I couldn't find out why there were badly formed 'br' tags being outputted from the RTE (I'm guessing this may be an issue with Tiny MCE?), I simply did a .Replace("<br >", "<br/>") on the output of the RTE.

    My other tag issue was with 'p' tags. What was actually getting outputted was something like this: "<p><p>Texty texty text text</p>"; An extra opening 'p' tag, without it's closing counterpart. Again I'm not entirely sure why this was happening, but my solution was to to feed the HTML into a HtmlDocument from HtmlAgilityPack, then saving it back out into a string. HtmlAgilityPack magically closes any unclosed tags (I think because it saves it through an XmlWriter which does it for you).

    Anyway, that was how I solved my problem! Now on to PDF creation heaven!

    Regards,

    Jamie

Please Sign in or register to post replies

Write your reply to:

Draft