Forum Discussion

Bl0ckS1z3's avatar
Bl0ckS1z3
Copper Contributor
Jul 21, 2023

Can't read RSS Feed from Joomla 4 using different RSS-Classes

Hello,

 

I built a litte RSS-Feed-Reader for my companies intranet site built on joomla cms, to inform the users of new articles showing a windows taskbar balloon message using visual studio .NET application.

Everything was working perfect for years, but now I need to upgrade to joomla 4.

I created a test intranet page and upgraded it to joomla 4. Everything works fine, but now I run into a problem I can't solve for about 4 weeks, driving me insane.

 

My application was designed to use the System.Xml.Linq class to read the rss feed.

 

 

string feedUrl = "https://some rss feedurl";

XDocument rssfeedxml;
XNamespace namespaceName = "http://www.w3.org/2005/Atom";
rssfeedxml = XDocument.Load(feedUrl);

 

 

If I run the application I get an Exception :

 

System.Xml.XmlException: Es sind mehrere Stammelemente vorhanden. Zeile 2, Position 2.
bei System.Xml.XmlTextReaderImpl.Throw(Exception e)
bei System.Xml.XmlTextReaderImpl.ParseDocumentContent()
bei System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
bei System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
bei System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
bei System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)

 

So I tried to switch to using System.ServiceModel.Syndication class

 

 

XmlReaderSettings settings = new XmlReaderSettings();

settings.ConformanceLevel = ConformanceLevel.Fragment;

var reader = XmlReader.Create(feedUrl,settings);
var feed = SyndicationFeed.Load(reader);

 

 

If I run this code, I get also an Exception :

 

System.Xml.XmlException: Das Element mit dem Namen 'br' und dem Namespace '' ist kein zulässiges Feedformat.
bei System.ServiceModel.Syndication.SyndicationFeed.Load[TSyndicationFeed](XmlReader reader)

 

If I switchback the feedurl to joomla 3 everything works fine again on both classes.

 

If I use the joomla 4 rss-link in FeedReader 3 the feed is loaded.

If I download the xml file using the rss-feed link and do a xml-analysis in notepad++ no problems were found.

 

That drives me crazy. What is the problem on this?

 

best regards

 

Bl0ckS1z3

 

 

 

 

 

  • Bl0ckS1z3's avatar
    Bl0ckS1z3
    Copper Contributor

    Hello,

     

    I found out, that in joomla 3 if there is a linebreak in the CDATA there is always a CR/LF. In joomla 4 there is only a LF.

    This is the only relevant difference I could find between the xml-Code of the different feeds.

     

    The Syndicate-Classes I use seem not be able to deal with that.

     

    What can I do? Any suggestionsß

     

    best regards.

     

     

Resources