Updating search controls Options
imayat12
Posted: Wednesday, August 16, 2006 5:43:55 PM

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.
imayat12
Posted: Friday, August 18, 2006 11:04:59 AM

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.
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.