2012-07-30 64 views
0

我正在使用ASP.Net的内置类为网站创建XML Feed。下面的代码我有,使用HTML标记格式化XML Feed中的Title元素

SyndicationFeed myFeed = new SyndicationFeed(); 
myFeed.Title = TextSyndicationContent.CreatePlaintextContent 
("XYZ - In the first line <br/> in the second line"); 

呈现时它显示,因为它是 -

XYZ - In the first line <br/> in the second line 

,而我希望它

XYZ - In the first line 
in the second line 

我看到的行为只是为了myFeed.Title ,而在myFeed.Description中,我可以使用任何HTML标签。

任何获得使用标题的HTML标签的方法?

+0

如果这是您使用html解码的实际情况,或者您可以在xml文件中进行更改,则可以将数据保存在CDATA块中。 – 2012-07-30 16:00:54

+0

都尝试过,但似乎没有效果。 – itsbalur 2012-07-30 16:10:55

回答

0

改为使用SyndicationContent.CreateHtmlContent Method。 SyndicationContent.CreatePlaintextContent总是转义文本以使其逐字呈现。

+0

我试过这个选项,但HTML标签没有得到应用。 – itsbalur 2012-07-30 16:11:44

+0

如果您查看原始供稿内容,标签在该处是否正确显示?这可能是一个客户端呈现问题。 – JamieSee 2012-07-30 16:30:20

+0

是的,供稿内容在源中正确显示。可能是它的一个客户端问题,但它在IE8/9或Mozilla 14中无法正常工作。我需要让它们至少在IE中工作。 – itsbalur 2012-07-31 02:21:54