Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Is there a faster way to get a typed value from XPath?

$
0
0

Hi all;

We create an XPathNavigator that is given an XML and XSD file. When we want a typed value from an XPath query, our code is:

// XPathNavigator nav; created at the start.
// string xpath is the xpath.
// XsltArgumentList parameters; created & populated above. Usually empty.

private object SelectSingleNodeTyped(XPathNavigator nav, string xpath, XsltArgumentList parameters)
{

// XPathCustomContext context is a class variable created above

context.ArgList = parameters;
XPathExpression exp = nav.Compile(xpath);
exp.SetContext(context);

					object obj = nav.Evaluate(exp);

					XPathNodeIterator it = obj as XPathNodeIterator;
					if (it != null)
					{
						if (!it.MoveNext())
							return null;

						object rtn = it.Current.TypedValue;

						return rtn;
					}

					//either a bool, Double, string

					return obj;
}

The above all works great. However, it's 10% of the total execution time of my app when running. Is there a better way to get the result of an XPath select for a single node, with a typed result? And by better I mean faster.

??? - thanks - dave


Who will win The Windward International Collegiate Programming Championships?


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>