简体   繁体   English

如何将CSS样式表添加到WCF生成的RSS feed?

[英]How do I add a CSS stylesheet to a WCF generated RSS feed?

I have a WCF service that uses a System.ServiceModel.Syndication.SyndicationFeed to create an RSS feed. 我有一个WCF服务,该服务使用System.ServiceModel.Syndication.SyndicationFeed创建RSS提要。

But I'm having trouble figuring out how to add a Processing Instruction to output that points to my CSS stylesheet. 但是我很难弄清楚如何添加处理指令以输出指向我的CSS样式表的内容。

What I need is a processing instruction that looks a bit like this: 我需要的是一条看起来像这样的处理指令:

<?xml-stylesheet type="text/css" href="http://you.com/rss.css" ?>

Anyone have a hint how you add that using SyndicationFeed ? 任何人都有提示,您如何使用SyndicationFeed进行添加?

I am not familiar with WCF, but I found this . 我不熟悉WCF,但是发现了这一点 I think this might help you out. 我认为这可能会帮助您。

http://www.developmentnow.com/g/8_2008_2_0_0_1041398/xslt-and-System-ServiceModel-Syndication.htm http://www.developmentnow.com/g/8_2008_2_0_0_1041398/xslt-and-System-ServiceModel-Syndication.htm

Since your contract is going to return an instance of SyndicationFeedFormatter, which implements IXmlSerializable, I would have your method on the service contract get that instance, then call the methods on IXmlSerializable to serialize the output to XML. 由于您的合同将要返回一个实现IXmlSerializable的SyndicationFeedFormatter实例,因此我会让服务合同上的方法获取该实例,然后调用IXmlSerializable上的方法将输出序列化为XML。 You can then add the processing instruction to the XML (XDocument, or XmlDocument) and then pass those contents back. 然后,您可以将处理指令添加到XML(XDocument或XmlDocument)中,然后将这些内容传回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM