tags:

views:

31

answers:

1

Hello there,

I have a readonly xml file and I have a set of xpath values. I need to create a function which would take in the xpath and return the value(s) corresponding to the xpath.

I am a little confused regarding what would be the best way to proceed. The options I am thinking are using the regular XPathDocument/Navigator/Iterator classes or using LINQ to xml.

The function I am trying to implement is:

T GetString(string inputXpath) where T could be bool/string/array etc.

Can someone help?Also, this function is going to be called all across the application, so performance might be a consideration.

Thank you! -Agent

A: 

What you want to write will just return:

XpathNavigator.Evaluate(inputXpath);

Obviously, T must be just... object :)

Read the XpathNavigator.Evaluate() documentation here.

Dimitre Novatchev