How to convert xml to style so that browser can render html from xml when using RSS

peter liles 556 Reputation points
2023-01-30T01:05:53.09+00:00

I have downloaded a app called MessageBoard and trying to configure RSS Feed to output serialised data to browser. The result display a error message with code written in xml format.

This XML file does not appear to have any style information associated with it.

Therefore How do i setup and add such a file ?

The method


        Public Function GetLatestMessages(ByVal format As FeedFormat) As SyndicationFeedFormatter Implements IFeedService.GetLatestMessages
            Dim rootUri As Uri = GetRootUri(
                       Dim feed As SyndicationFeed = New SyndicationFeed("Message Board", "A sample message board built using Visual Studio 2008.", rootUri)

               feed.Items = From m In MessageProvider.GetRecentMessages(0, 10) Select CreateSyndicationItem(m, rootUri)
          
                   

            If format = FeedFormat.Atom Then Return New Atom10FeedFormatter(feed)
            Return New Rss20FeedFormatter(feed)
         
        End Function


        Private Function CreateSyndicationItem(ByVal m As Message, ByVal rootUri As Uri) As SyndicationItem
          
            Dim uriBuilder As UriBuilder = New UriBuilder(rootUri)
            uriBuilder.Path += "/Message.aspx"
            uriBuilder.Query = "id=" & m.topicId.ToString(CultureInfo.InvariantCulture)

      
            'The Syndic
            Dim item = New SyndicationItem(m.TopicSubject,
                                           m.TopicBody,
                                           uriBuilder.Uri,
                                           m.topicId.ToString(),
                                           New DateTimeOffset(m.topiccreateDate, New New TimeSpan(0)))
           
     
  Return item
        End Function
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,250 questions
{count} votes

Accepted answer
  1. 2023-03-28T22:28:04.0866667+00:00
    http://www.tg.com/resolve?domain=seha_sa&post=7678
    

    Dim rssWriter As XmlWriter = XmlWriter.Create("rss.xml")

            rssWriter.WriteProcessingInstruction("xml-stylesheet",
    
                                                 "type='text/xsl' href='XSLTFile.xslt'")
    
            Dim rssFormatter As Rss20FeedFormatter = New Rss20FeedFormatter(feed)
    
            rssFormatter.WriteTo(rssWriter)
    
            rssWriter.Close()
    
            Return rssFormatter
    

    The system returns a request error message:

    The server encountered an error processing the request. The exception message is 'Access to the path 'C:\Program Files (x86)\IIS Express\rss.xml' is denied.'. See server logs for more details.

    The stack trace ends at first line shows.so i assume that the feed is readonly ?

    so how may i edit the file to write the xls sheet address and then return edited version as shown on original question.

    I wish there was a working example of rss.

    0 comments No comments

11 additional answers

Sort by: Most helpful
  1. QiYou-MSFT 4,306 Reputation points Microsoft Vendor
    2023-02-20T06:56:38.72+00:00

    Hi @peter liles

    I devised a methodology based on your ideas.

    1.Use SyndicationFeed with WCF to write an xml file on a URL.(There are examples of this step in the documentation you gave me.)

    2.Write an XSLT document.

    3.Use code to bring them together.

    Private Sub SurroundingSub()
        Dim myXslTrans = New XslCompiledTransform()
        myXslTrans.Load("C:\Users\Administrator\Desktop\Test.xsl")
        myXslTrans.Transform("http://localhost:8000/BlogService/GetBlog", "C:\Users\Administrator\Desktop\result.html")
    End Sub
    

    Since the XML file you generate in this method is on this URL, the first variable is directly the URL. You can also take a path address string.

    Finally, it is sent to WebForm through the principle of wcf (ABC).

    Of course, this method generates an html file. You can do it directly with VB without WCF. Then use it in webform according to your needs.

    Test2_20 1

    Test2_20 2

    Best Regards

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. peter liles 556 Reputation points
    2023-01-31T01:37:43.5466667+00:00

    The info is informative as it shows how to format a xml doc with CSS.

    The problem with my issue is that the output xml data is automatically generated from the script method and read only. So i therefore need to insert a style formatting sheet such as XSLT

    I read about XSLT doc to transform XML to Html being the preferred choice. But i cannot find a file that exists in Add new item list showing extension .XLS as mention in documents?

    0 comments No comments

  3. peter liles 556 Reputation points
    2023-01-31T01:44:36.6233333+00:00

    The XML file is automatically generated and readonly.

    From what i read it requires a XSLT doc to transform into HTML.

    The problem now is i cant find a file with extension XSL in Add new item of solution explorer? that i can attach

    I am using Edge browser

    0 comments No comments

  4. QiYou-MSFT 4,306 Reputation points Microsoft Vendor
    2023-01-31T05:40:41.0466667+00:00

    Hi @peter liles

    You mean you can't find the file with the XSL suffix in Explorer. First we can create a new Text Document on the desktop.

    Then we enter the corresponding xsl data, and finally select "all file" when saving as, and set the name to "Test.xsl".Finally, save to Explorer.

    Test1

    Test2

    Test3

    Typically, the resource manager is available for new ones.

    Test1

    Best Regards

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments