472,122 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

C# RSS feed generator & building the guid element

2
Windows XP Pro
VS 2005 & C# (I'm fairly new to C# but have doing VB.Net going on 2yrs and VB6 for 5yrs.)

I'm using C# to build a custom RSS generator. I'm having trouble building the guid element for each item node in my feed. Some items do not have the "link" node because the description element is the content. So using the "link" as the guid will not work in my case, as some sites suggest and as feedvalidator.org complains when I do not have one. Plus the content may change so I'm attempting to set the isPermaLink attribute to false to instruct the RSS readers/subscribers not to use this field; it's just there for uniqueness.

Here is what I need:
<guid isPermaLink="false">69DA.....383D26EAF0</guid>

I have tried building a "guid" object but when its serialized it takes each property and makes them attributes of the guid element. Like this:
<guid guid="69DA......383D26EAF0" isPermaLink="false" />
Which is represented by the code snippet below.
Here's my "guid" element:
Expand|Select|Wrap|Line Numbers
  1. [XmlElement("guid")]
  2. public guidAttributes Guid
  3.  get    { return _guid;     }
  4.  set    { _guid = value; }
  5. }
  6.  
Here is my guidAttributes class:
Expand|Select|Wrap|Line Numbers
  1. public class guidAttributes
  2. {
  3.  private string _guid;
  4.  private bool _isPermaLink;
  5.  
  6.  [XmlAttribute("guid")]
  7.  public string Guid
  8.  {
  9.   get {  return _guid; }
  10.   set { _guid = value; }
  11.  }
  12.  
  13.  [XmlAttribute("isPermaLink")]
  14.  public bool isPermaLink
  15.  {
  16.   get {  return _isPermaLink; }
  17.   set { _isPermaLink = value; }
  18.  }
  19. }
  20.  
Changing the "guid" property above from Attribute to element like this:
Expand|Select|Wrap|Line Numbers
  1. [XmlElement("guid")]
  2.  public string Guid
  3.  
Produces this output:
<guid isPermaLink="false">
<guid>69DA.....383D26EAF0</guid>
</guid>

I'm close but not there and just need a bit of help to put all the pieces together.

Any help is greatly appreciated.

Thanks,

Michael
Nov 10 '06 #1
2 14758
Troll
2
Well a co-worker helped me out. Pretty simple in retrospect. I would post the code but everyone else must know how to do it or have no need for the implementation. If you do need to see the code, let me know.

Mike
Nov 16 '06 #2
karlomanio
1 Bit
I'd like to see your solution.

Thanks,
karlomanio
Jan 14 '22 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Al | last post: by
5 posts views Thread by Ed Flecko | last post: by
4 posts views Thread by Blake Garner | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.