The following line:
string cellData = d.XPathSelectElement(cellSelector).Value;
Throws an exception stating “The XPath expression evaluated to unexpected type System.Double.”
The CellSelector contains: “./Units * ./product/Cost”
The Data in XElement d is:
<LineItem>
<product>
<ProductId>22</ProductId>
<ProductName>Car Cleaning</ProductName>
<Cost>26.02</Cost>
</product>
<Units>2</Units>
</LineItem>
In this example, I need the output of that line to be “52.04” and even more ideally, I’d love it to be “£ 52.04”.
What would the XPathExpression have to look like to accomplish that?
I tried changing the expression to “String(./Units * ./product/Cost)” but that generates the exception “The XPath expression evaluated to unexpected type System.String.” which I would expect to have worked.
XPathEvaluateseems to be what you want: