We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19889
    • 616 Posts
    Hello
    I’m looking for some ideas and solutions to solve the following problem:

    I’m getting an RSS feed that is un-properly formatted - html tags are opened and not closed, invalid attributes and the like - stripping all the tag out of the feed would be o.k. - however, the feed also contains an image I like to preserve and show on the page.

    One thing I was considering is showing the feed in an iframe hoping that the page would validate then but I haven’t tried yet.

    Does anybody have a function that would clean out all the html tags - just leave the plain text as well as the image and possibly fix invalid attributes of the image as well?

    Thank you in advance for your help.
      • 27708 MODX Staff
      • 2,502 Posts
      Are you wanting the output of an RSS feed to be valild HTML? I don’t quite understand. RSS feeds are XML. If you have an RSS feed being parsed onto the page, you may need to fix the output template used.

      Please provide more detail.

      Cheers,

      Jay
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 19889
        • 616 Posts
        Yes, I’d like the page to be valid xhtml - all the rest actually is - it’s just the RSS feed that screws up everything - I’m using FeedX to get the info - phx:notags actually cleans up everything just fine - however it also deletes the image that’s contained in the feed and I’d like to keep that. I don’t thing there is anything else that I could do in the template but having a custom phx rule that would clean things up but keep the image.
          • 27708 MODX Staff
          • 2,502 Posts
          You want this: http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:striptags

          I was gonna write it but figured it might be there already it was.

          Cheers,

          Jay
            Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
            • 19889
            • 616 Posts
            doesn’t seem to work for me - I’m not getting anything but the link to the article now - this is what I’m using:
            <div class="slide">
            	<a href="[+LINK+]" title="[+PUBDATE+]" rel="external">[+TITLE+]</a><br />
            	<div class="item">[+DESCRIPTION:striptags=`<img>`+]</div>
            </div>
            


            Interesting - if I create a custom snippet and put
            <?php
            $options = '<img>';
            return($modx->stripTags($output, $options));
            ?>
            
            

            then it works?