How do you convert a string to a node in XQuery?
marklogic, xml, xquery
Solution
MarkLogic solutions:
The best way to convert a string into a node is to use:
xdmp:unquote($string).
Conversely if you want to convert a node into a string you would use:
xdmp:quote($node).
Language agnostic solutions:
Node to string is:
fn:string($node)
Problem
I would like to convert a string into a node. I have a method that is defined to take a node, but the value I have is a string (it is hard coded). How do I turn that string into a node? So, given an XQuery method: ``` define function foo($bar as node()*) as node() { (: unimportant details :) } ``` I have a string that I want to pass to the foo method. How do I convert the string to a node so that the method will accept the string.