C# RSS feed generator & building the guid element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Troll
    New Member
    • Nov 2006
    • 2

    C# RSS feed generator & building the guid element

    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.o rg 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="fa lse">69DA.....3 83D26EAF0</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="fa lse" />
    Which is represented by the code snippet below.
    Here's my "guid" element:
    Code:
    [XmlElement("guid")]
    public guidAttributes Guid
    { 
     get	{ return _guid;	 }
     set	{ _guid = value; }
    }
    Here is my guidAttributes class:
    Code:
    public class guidAttributes
    {
     private string _guid;
     private bool _isPermaLink;
    
     [XmlAttribute("guid")]
     public string Guid
     {
      get {  return _guid; }
      set { _guid = value; }
     }
    
     [XmlAttribute("isPermaLink")]
     public bool isPermaLink
     {
      get {  return _isPermaLink; }
      set { _isPermaLink = value; }
     }
    }
    Changing the "guid" property above from Attribute to element like this:
    Code:
    [XmlElement("guid")]
     public string Guid
    Produces this output:
    <guid isPermaLink="fa lse">
    <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
  • Troll
    New Member
    • Nov 2006
    • 2

    #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

    Comment

    • karlomanio
      New Member
      • Jan 2022
      • 1

      #3
      I'd like to see your solution.

      Thanks,
      karlomanio

      Comment

      Working...