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
- [XmlElement("guid")]
- public guidAttributes Guid
- {
- get { return _guid; }
- set { _guid = value; }
- }
Expand|Select|Wrap|Line Numbers
- 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; }
- }
- }
Expand|Select|Wrap|Line Numbers
- [XmlElement("guid")]
- public string Guid
<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