peter3244
asked on
Using xPathNav.Compile, its returning a node set how can I access the nodeset C# 2005?
Using xPathNav.Compile, its returning a node set how can I access the nodeset C# 2005?
When xpathExpr.ReturnType = XPathResultType.NodeSet
how do I access the properties of this node set
object functionReturnValue = xPathNav.Select(xpathExpr) ;
ie does not return what i want as i just want the node not a XPathNavigator
When xpathExpr.ReturnType = XPathResultType.NodeSet
how do I access the properties of this node set
object functionReturnValue = xPathNav.Select(xpathExpr)
ie does not return what i want as i just want the node not a XPathNavigator
public object GetXpath(XmlNode node, string xPath)
{
object functionReturnValue = null;
string errorMsg = "TransmitMessage::XPath expression {0} is invalid. " + xPath;
try {
XPathNavigator xPathNav = node.CreateNavigator();
XPathExpression xpathExpr = xPathNav.Compile(xPath);
switch (xpathExpr.ReturnType)
{
case XPathResultType.Boolean:
functionReturnValue = xPathNav.Evaluate(xpathExpr);
break;
case XPathResultType.String:
functionReturnValue = xPathNav.Evaluate(xpathExpr);
break;
case XPathResultType.Number:
functionReturnValue = xPathNav.Evaluate(xpathExpr);
break;
case XPathResultType.NodeSet:
// how do I access this nodeset
functionReturnValue = xPathNav.Select(xpathExpr);
break;
case XPathResultType.Error:
GenericLogger.ErrorLog(errorMsg);
functionReturnValue = errorMsg;
throw new Exception(errorMsg);
default:
functionReturnValue = errorMsg;
throw new Exception(errorMsg);
}
}
catch (Exception exp)
{
functionReturnValue = exp.Message + " " + errorMsg;
GenericLogger.ErrorLog(_userName, _machineName, errorMsg);
throw new Exception(errorMsg);
}
return functionReturnValue;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.