Copied to clipboard

Flag this post as spam?

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

  • rendervouz 6 posts 126 karma points
    Sep 08, 2016 @ 08:41

    Consuming RSS from a file with a .PHP format

    I'm currently trying to consume an RSS from other sites. The problem is, the rss is in a .php format. (But it's actually XML, if you view the source)

    I'm trying to do it with

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using System.Xml;
        //Get the XML from remote URL
        XmlDocument xml = new XmlDocument();
        //URL currently hardcoded - but you could use a macro param to pass in URL
        //Select the nodes we want to loop through
        XmlNodeList nodes = xml.SelectNodes("//item");
        //Traverse the entire XML nodes.
        foreach (XmlNode node in nodes)
            //Get the value from the <title> node
            var title = node.SelectSingleNode("title").InnerText;
            //Get the value from the <description> node
            var description = node.SelectSingleNode("description").InnerText;

    But it gives me errors.

    However, I've tried to change the rss url to other file ( which is in .xml format and it works fine

    Is it possible to consume the RSS if the provided file is in .php format? If yes, what is the possible way to do that? Thanks!

  • Sven Geusens 161 posts 869 karma points c-trib
    Sep 13, 2016 @ 15:46
    Sven Geusens


    It might have something to do with the fact that the xml rendered by the php file is not valid xml.

    Just view the source, copy the entire thing and paste it into any xml validator. eg:

    I have a feeling that the error you are getting is a XmlException error.

    Further documentation on XmlDocument.Load() might help you better understand how the function works:

    Hope this helps you out.


Please Sign in or register to post replies

Write your reply to: