Type: String

XPath and XQuery are the preferred way of traversing a DOM in Fonto. Using XQuery, you can easily look up a node, search for an attribute, create an element structure, or compare the textual content of nodes.

XPath and XQuery can be tested using the XPath test app, which can be found at https://xpath.playground.fontoxml.com.

See the XPath 3.1 and the {@link https://www.w3.org/TR/xquery-31/ XQuery 3.1} spec for more information.

The implementation used by Fonto is open source, it can be found at the github page.


1 + 1


declare function local:fingerprint ($node) {
  typeswitch ($node)
    case element() return name($node)
    default return string($node)

for $node in child::node() return local:fingerprint($node)


for $node in child::node() return <a-child>{$node}</a-child>


 : It is even possible to use XQuery update facility here,
 : as long as they only use the copy/modify/return syntax:
for $e in //employee[skill = "Java"]
  copy $je := $e
  modify delete node $je/salary
  return $je