Inheriting XMLNodelist
-
Wednesday, April 09, 2008 3:26 PM
Hi all,
I was able to derive/inherit the XmlDocument and XmlElement as MyDocument and MyElement respectively. But now I want to inherit the XmlNodelist calls to my custom class as MyElementList so that I can return the output of SelectNodes(BCL returns as XmlNodeList) as MyElementList.
MyDocument : XmlDocument
{
new MyElementList SelectNodes(string xpath)
{
return (MyElementList)base.SelectNodes(xpath);
}
}
MyElement : XmlElement
{
}
MyElementList : XmlNodeList
{
}
Any help/suggestion on this is appreciated.
Thanks
Gabi
All Replies
-
Thursday, April 10, 2008 9:38 AMModerator
I think you need to implement IEnumerable interface on your XmlNodeList and add a constructor which can accept XmlNodeList. Then your SelectNodes implementation would look as follows:
Code Snippetnew MyElementList SelectNodes(string xpath){
return new MyElementList(base.SelectNodes(xpath));}
Out of curiosity - why do you need to derive from these Xml classes?
Pawel
-
Thursday, April 10, 2008 3:59 PM
Pawel,
Thanks for your timely help. I am deriving this class such that developers can use only the custom class.
Thanks
Gabriel

