Did you notice QXmlQuery? It makes exactly what your custom function does...