 Rank: Addict
Joined: 7/19/2006 Posts: 649 Location: Preston, UK
|
Guys,
I am working on updating the umbraco search so that it will also index non html stuff from the media library.
I am having problem with some code namely
XmlNode node = ((IHasXmlNode)umbraco.library.GetMedia(int.Parse(TextBox1.Text),false).Current).GetNode();
this works the textbox contains id of media item. The problem I have is when i try to get attributes of the node i get null reference error. However when i view the outerxml i can see the attributes.
Any ideas? Also is there a better way of actually getting the media node?
Regards
Ismail
Level 2 certified. If it aint broke dont fix.
|
 Rank: Addict
Joined: 7/19/2006 Posts: 649 Location: Preston, UK
|
Ok sorted this. The issue is that the orignal document that the node came from was an XPathDocument.
Two ways round this problem easy less efficient way which is to take the node xml and load it into dom document then you can get all the properties or more efficient way which is to create xpathnavigator off the node and iterate that way suffice to say i went for lazy option namely
XmlNode node = ((IHasXmlNode)umbraco.library.GetMedia(int.Parse(TextBox1.Text),false).Current).GetNode();
if(node!=null) { XmlDocument x = new XmlDocument(); x.LoadXml(node.OuterXml); //do some stuff
}
and for brevity the other way
XmlNode node = ((IHasXmlNode)umbraco.library.GetMedia(int.Parse(TextBox1.Text),false).Current).GetNode(); XPathNavigator xnav = node.CreateNavigator();
Regards
Ismail
Level 2 certified. If it aint broke dont fix.
|