Difference between revisions of "XQUERY()"

From Lianjapedia
Jump to: navigation, search
(Created page with "==Purpose== Used to parse XML strings using Xquery notation ==Syntax== XQUERY(<expC1>, <expC2>) ==See Also== MQCLOSE(), MQCREATE(), MQCURMSGS(), MQOPEN(), [...")
 
Line 57: Line 57:
  
 
<code lang="recital">
 
<code lang="recital">
 +
// Examples using mybooks.xml
 
cMybooks = filetostr("mybooks.xml")
 
cMybooks = filetostr("mybooks.xml")
 
cBook = xquery(cMybooks,"/bookstore/book[2]")
 
cBook = xquery(cMybooks,"/bookstore/book[2]")

Revision as of 08:33, 16 February 2016

Purpose

Used to parse XML strings using Xquery notation

Syntax

XQUERY(<expC1>, <expC2>)

See Also

MQCLOSE(), MQCREATE(), MQCURMSGS(), MQOPEN(), MQSEND(), MQRECEIVE(), MQUNLINK(), XML_DECODE(), XML_ENCODE(), XML_GATHER(), XML_SCATTER(), XQUERY_CLOSE(), XQUERY_COUNT(), XQUERY_DECODE(), XQUERY_FILE(), XQUERY_FIND(), XQUERY_OPEN()

Description

The XQUERY() function is used to parse XML strings using Xquery notation. The XQUERY() function returns a character string. The character expression <expC1> is the XML string; <expC2> is the XML tag name.

Example

mybooks.xml

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
 
<book category="COOKING">
  <title lang="en">Pulse</title>
  <author>Jenny Chandler</author>
  <year>2013</year>
  <format>Hardback</format>
</book>
 
<book category="COOKING">
  <title lang="en">Riverford Farm Cook Book</title>
  <author>Guy Watson</author>
  <author>Jane Baxter</author>
  <year>2008</year>
  <format>Paperback</format>
</book>
 
<book category="CHILDREN">
  <title lang="en">The House At Pooh Corner</title>
  <author>A. A. Milne</author>
  <year>1928</year>
  <format>Hardback</format>
</book>
 
<book category="CRIME">
  <title lang="en">Knots and Crosses</title>
  <author>Ian Rankin</author>
  <year>2008</year>
  <format>EPUB</format>
</book>
 
<book category="PHILOSOPHY">
  <title lang="fr">Le mythe de Sisyphe</title>
  <author>Albert Camus</author>
  <year>1943</year>
  <format>Paperback</format>
</book>
 
</bookstore>
// Examples using mybooks.xml
cMybooks = filetostr("mybooks.xml")
cBook = xquery(cMybooks,"/bookstore/book[2]")
? cBook
 
  <title lang="en">Riverford Farm Cook Book</title>
  <author>Guy Watson</author>
  <author>Jane Baxter</author>
  <year>2008</year>
  <format>Paperback</format>
 
cMybooks = filetostr("mybooks.xml")
cTitle = xquery(cMybooks,"/bookstore/book[2]/title")
? cTitle
 
Riverford Farm Cook Book