SYNOPSISstring[] xmlTreeQuickXPath(string xmlRaw, string xpathQuery
[, string[] xmlns)
Parameters:
xmlRaw
- the plain text of the XML document you want to
extract information fromxpathQuery
- the XPath expression that identifies the
nodes you want to extract the data fromxmlns
(optional) - an array of prefix=URI
namespaces to use in the XPath query
Returns:
xmlRaw
that match xpathQuery
DESCRIPTIONxmlTreeQuickXPath
allows you to easily extract information from
an unparsed 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($xpath, $xpathQuery))>
<loop $nodes>
<$ret = (xmlTreeGetAllContent($nodes))>
<$content = $content $ret>
</loop>
EXAMPLE
if the xmlData
field of a table has content like this:
<extraInfo>
<price>8.99</price>
<author>John Doe</author>
<isbn>978-0-06-051280-4</isbn>
</extraInfo>
Then the following SQL statement will match that row:
SELECT * from myTable where xmlTreeQuickXPath(data,
'/extraInfo/author') = 'John Doe'
SEE ALSOxmlTreeNewXPath
,
xmlTreeXPathExecute
,
xmlTreeXPathRegisterNs