Extracts information from an XML document.

xmlTreeQuickXPath(string xmlRaw, string xpathQuery
        [, string[] xmlns)


  • xmlRaw - the plain text of the xml document you want to extract information from

  • xpathQuery - the XPath expression that identifies the nodes you want to extract the data from

  • xmlns (optional) - an array of prefix=URI namespaces to use in the XPath query


  • String values of the node from the XML document xmlRaw that match xpathQuery

xmlTreeQuickXPath allows you to easily extract information from an XML document in a one-shot function. It is intended to be used in SQL statements to extract specific information from a field that contains XML data.

It is essentially a one statement version of the following:

<$doc = (xmlTreeNewDocFromString($xmlRaw))>
    <$xpath = (xmlTreeNewXPath($doc))>
    <$nodes = (xmlTreeXPathExecute($xpathQuery))>
    <loop $nodes>
        <$ret = (xmlTreeGetAllContent($nodes))>
        <$content = $content $ret>

if the xmlData field of a table has content like this:

    <author>John Doe</author>

Then the following SQL statement will match that row:

SELECT * from myTable where xmlTreeQuickXPath(data,
'/extraInfo/author') = 'John Doe'

Copyright © Thunderstone Software     Last updated: Oct 5 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.