如何添加SyndicationElementExtension给一个SyndicationItem [英] How To Add A SyndicationElementExtension To A SyndicationItem

查看:234
本文介绍了如何添加SyndicationElementExtension给一个SyndicationItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用.NET System.ServiceModel.Syndication类...

我想一个新的SyndicationElementExtension添加到SyndicationItem,将导出以下XML:

 <媒体:缩略图的URL =htt​​p://www.foo.com/keyframe.jpgWIDTH =75高度=50时间=12:05 :01.123/>
 

线沿线的东西:

  syndicationItem.ElementExtensions.Add(新SyndicationElementExtension(缩略图,http://video.search.yahoo.com/mrss?
 

你怎么有几个属性创建一个简单的SyndicationElementExtension?

解决方案

在这里找到了答案:<一href="http://msdn.microsoft.com/en-us/library/bb943475.aspx">http://msdn.microsoft.com/en-us/library/bb943475.aspx

  

本   SyndicationElementExtensionCollection   类也可以用于创建   从一个XmlReader元素扩展   实例。这可以很容易地   用XML处理的API集成   如的XElement中所示   下面的示例code。

  feed.ElementExtensions.Add(新的XElement(xElementExtension
        新的XElement(钥匙,新XAttribute(attR1位,someValue中),Z),
        新的XElement(价值,新XAttribute(attR1位,someValue中),
        15))CreateReader())。
 

Using the .NET System.ServiceModel.Syndication classes...

I would like to add a new SyndicationElementExtension to a SyndicationItem that will export the following XML:

<media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123" />

Something along the lines of:

syndicationItem.ElementExtensions.Add(new SyndicationElementExtension("thumbnail", "http://video.search.yahoo.com/mrss", ?

How do you create a simple SyndicationElementExtension with a few attributes?

解决方案

Found the answer here: http://msdn.microsoft.com/en-us/library/bb943475.aspx

The SyndicationElementExtensionCollection class can also be used to create element extensions from an XmlReader instance. This allows for easy integration with XML processing APIs such as XElement as shown in the following sample code.

feed.ElementExtensions.Add(new XElement("xElementExtension",
        new XElement("Key", new XAttribute("attr1", "someValue"), "Z"),
        new XElement("Value", new XAttribute("attr1", "someValue"), 
        "15")).CreateReader());

这篇关于如何添加SyndicationElementExtension给一个SyndicationItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆