79614615

Date: 2025-05-09 17:33:13
Score: 4
Natty:
Report link

I have the same issue when writing custom functions for XPath evaluation in .NET C#, using XSLT inheritance. When text() is provided as argument, it turns into the type XPathSelectionIterator that is mentioned in the question's title.

The solution for me was to match it with the XPathNodeIterator type in a pattern and access the string as Current?.Value.

var stringValue = arg[0] switch
{
    string s => s,
    XPathNodeIterator i => i.Current?.Value ?? ""
    _ => ""
};
Reasons:
  • Blacklisted phrase (1): I have the same issue
  • Has code block (-0.5):
  • Me too answer (2.5): I have the same issue
  • Low reputation (1):
Posted by: Criselmof