open database southwind select * from shippers into object shipobj print_xml(shipobj)
1Speedy Express(503) 55 2United Package(503) 55 3Federal Shipping(503)
https://www.lianja.com/doc/index.php/PRINT_XML()
set xmlformat to ADO SELECT * FROM example; SAVE AS XML example // In Visual Basic the file can then be loaded like this: // Set adoPrimaryRS = New Recordset // adoPrimaryRS.Open "example.xml" // Excel example set xmlformat to excel open database southwind use customers copy to mycustomers.xml type xml Lianja.showDocument("mycustomers.xml")
https://www.lianja.com/doc/index.php/SET_XMLFORMAT
filename = geturl("http://www.myserver.com/getsomepage.rsp?name=smith&month=10", 30, array(), "myfilename.xml") myobject = xml_decode_file(filename, "customers", "customer")
https://www.lianja.com/doc/index.php/XML_DECODE_FILE()
open database southwind use shippers cVar = xml_scatter() copy structure to temp use temp append blank xml_gather(cVar)
https://www.lianja.com/doc/index.php/XML_GATHER()
// Proccess the message queue do while .t. // Check for new messages do while (mqcurmsgs(m_mqdes) > 0) // retrieve message m_message = mqreceive(m_mqdes) // decode the XML message into an object/dynamic array m_objmessage = xml_decode(m_message) // process the message mq_process_message(m_objmessage, m_message) enddo sleep 1 enddo
https://www.lianja.com/doc/index.php/XML_DECODE()
// Open up the queue for read/write access mqdes=mqcreate("/myqueue2", 2) if (mqdes < 0) messagebox(strerror()+",errno="+alltrim(str(error()))) return endif // send a message to the queue rc = mqsend(mqdes, xml_encode(tran_obj)) if (rc < 0) messagebox(strerror()+",errno="+alltrim(str(error()))) return endif mqclose(mqdes)
https://www.lianja.com/doc/index.php/XML_ENCODE()
// Open up the queue for read/write access mqdes=mqcreate("/myqueue2", 2) if (mqdes < 0) messagebox(strerror()+",errno="+alltrim(str(error()))) return endif // send a message to the queue rc = mqsend(mqdes, xml_encode(tran_obj)) if (rc < 0) messagebox(strerror()+",errno="+alltrim(str(error()))) return endif mqclose(mqdes)
https://www.lianja.com/doc/index.php/XML_ENCODE()
// Examples using mybooks.xml cMybooks = filetostr("mybooks.xml") cBook = xquery(cMybooks,"/bookstore/book[2]") ? cBook Guy Watson Jane Baxter 2008 Paperback cMybooks = filetostr("mybooks.xml") cTitle = xquery(cMybooks,"/bookstore/book[2]/title") ? cTitle Riverford Farm Cook Book
https://www.lianja.com/doc/index.php/XQUERY()
// Example using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount cTitle = xquery_node("/bookstore/book[&i]/title") ? cTitle oTitle = xquery_attributes("/bookstore/book[&i]/title") ? xquery_decode(oTitle) endfor xquery_close() // Results: Pulse Dynarray (refcnt=0) ( [title] => Dynarray (refcnt=1) ( [text] => Pulse [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) ) Riverford Farm Cook Book Dynarray (refcnt=0) ( [title] => Dynarray (refcnt=1) ( [text] => Riverford Farm Cook Book [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) ) The House At Pooh Corner Dynarray (refcnt=0) ( [title] => Dynarray (refcnt=1) ( [text] => The House At Pooh Corner [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) ) Knots and Crosses Dynarray (refcnt=0) ( [title] => Dynarray (refcnt=1) ( [text] => Knots and Crosses [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) ) Le mythe de Sisyphe Dynarray (refcnt=0) ( [title] => Dynarray (refcnt=1) ( [text] => Le mythe de Sisyphe [attributes] => Dynarray (refcnt=1) ( [lang] => fr ) ) )
https://www.lianja.com/doc/index.php/XQUERY_ATTRIBUTES()
// Examples using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount cTitle = xquery_find("/bookstore/book[&i]/title") ? cTitle endfor xquery_close() Pulse Riverford Farm Cook Book The House At Pooh Corner Knots and Crosses Le mythe de Sisyphe xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount nCountAuthor = xquery_count("/bookstore/book[&i]/author") for j = 1 to nCountAuthor cAuthor = xquery_find("/bookstore/book[&i]/author[&j]") ? cAuthor endfor endfor xquery_close() Jenny Chandler Guy Watson Jane Baxter A. A. Milne Ian Rankin Albert Camus
https://www.lianja.com/doc/index.php/XQUERY_CLOSE()
// Examples using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount cTitle = xquery_node("/bookstore/book[&i]/title") ? cTitle endfor xquery_close() Pulse Riverford Farm Cook Book The House At Pooh Corner Knots and Crosses Le mythe de Sisyphe xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount nCountAuthor = xquery_count("/bookstore/book[&i]/author") for j = 1 to nCountAuthor cAuthor = xquery_node("/bookstore/book[&i]/author[&j]") ? cAuthor endfor endfor xquery_close() Jenny Chandler Guy Watson Jane Baxter A. A. Milne Ian Rankin Albert Camus
https://www.lianja.com/doc/index.php/XQUERY_COUNT()
// Example using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount oBook = xquery_node("/bookstore/book[&i]") ? xquery_decode(oBook) endfor xquery_close() // Results: Dynarray (refcnt=0) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => Pulse [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) [author] => Dynarray (refcnt=1) ( [text] => Jenny Chandler [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 2013 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => Hardback [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => COOKING ) ) ) ) Dynarray (refcnt=0) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => Riverford Farm Cook Book [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) [author] => Dynarray (refcnt=1) ( [text] => Jane Baxter [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 2008 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => Paperback [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => COOKING ) ) ) ) Dynarray (refcnt=0) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => The House At Pooh Corner [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) [author] => Dynarray (refcnt=1) ( [text] => A. A. Milne [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 1928 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => Hardback [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => CHILDREN ) ) ) ) Dynarray (refcnt=0) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => Knots and Crosses [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) [author] => Dynarray (refcnt=1) ( [text] => Ian Rankin [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 2008 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => EPUB [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => CRIME ) ) ) ) Dynarray (refcnt=0) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => Le mythe de Sisyphe [attributes] => Dynarray (refcnt=1) ( [lang] => fr ) ) [author] => Dynarray (refcnt=1) ( [text] => Albert Camus [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 1943 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => Paperback [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => PHILOSOPHY ) ) ) )
https://www.lianja.com/doc/index.php/XQUERY_DECODE()
// Examples using mybooks.xml cBook = xquery_file("mybooks.xml","/bookstore/book[2]") ? cBook Guy Watson Jane Baxter 2008 Paperback cTitle = xquery_file("mybooks.xml","/bookstore/book[2]/title") ? cTitle Riverford Farm Cook Book nCount = 1 do while .T. cTitle = xquery_file("mybooks.xml","/bookstore/book[&nCount]/title") if empty(cTitle) exit endif ? cTitle ++ nCount enddo Pulse Riverford Farm Cook Book The House At Pooh Corner Knots and Crosses Le mythe de Sisyphe
https://www.lianja.com/doc/index.php/XQUERY_FILE()
// Examples using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount cTitle = xquery_find("/bookstore/book[&i]/title") ? cTitle endfor xquery_close() Pulse Riverford Farm Cook Book The House At Pooh Corner Knots and Crosses Le mythe de Sisyphe xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount nCountAuthor = xquery_count("/bookstore/book[&i]/author") for j = 1 to nCountAuthor cAuthor = xquery_find("/bookstore/book[&i]/author[&j]") ? cAuthor endfor endfor xquery_close() Jenny Chandler Guy Watson Jane Baxter A. A. Milne Ian Rankin Albert Camus
https://www.lianja.com/doc/index.php/XQUERY_FIND()
// Examples using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount cTitle = xquery_node("/bookstore/book[&i]/title") ? cTitle endfor xquery_close() Pulse Riverford Farm Cook Book The House At Pooh Corner Knots and Crosses Le mythe de Sisyphe xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount nCountAuthor = xquery_count("/bookstore/book[&i]/author") for j = 1 to nCountAuthor cAuthor = xquery_node("/bookstore/book[&i]/author[&j]") ? cAuthor endfor endfor xquery_close() Jenny Chandler Guy Watson Jane Baxter A. A. Milne Ian Rankin Albert Camus
https://www.lianja.com/doc/index.php/XQUERY_NODE()
// Examples using mybooks.xml xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount cTitle = xquery_node("/bookstore/book[&i]/title") ? cTitle endfor xquery_close() Pulse Riverford Farm Cook Book The House At Pooh Corner Knots and Crosses Le mythe de Sisyphe xquery_open("mybooks.xml") nCount = xquery_count("/bookstore/book") for i=1 to nCount nCountAuthor = xquery_count("/bookstore/book[&i]/author") for j = 1 to nCountAuthor cAuthor = xquery_node("/bookstore/book[&i]/author[&j]") ? cAuthor endfor endfor xquery_close() Jenny Chandler Guy Watson Jane Baxter A. A. Milne Ian Rankin Albert Camus
https://www.lianja.com/doc/index.php/XQUERY_OPEN()
// Examples using mybooks.xml xquery_open("mybooks.xml") xquery_select("book[@category='children']") obj = xquery_decode() ? obj xquery_close() // Results: Dynarray (refcnt=1) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => The House At Pooh Corner [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) [author] => Dynarray (refcnt=1) ( [text] => A. A. Milne [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 1928 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => Hardback [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => CHILDREN ) ) ) ) xquery_open("mybooks.xml") xquery_select("/bookstore/book[year>'2010']") obj = xquery_decode() ? obj xquery_close() // Results: Dynarray (refcnt=1) ( [book] => Dynarray (refcnt=1) ( [1] => Dynarray (refcnt=1) ( [title] => Dynarray (refcnt=1) ( [text] => Pulse [attributes] => Dynarray (refcnt=1) ( [lang] => en ) ) [author] => Dynarray (refcnt=1) ( [text] => Jenny Chandler [attributes] => Dynarray (refcnt=1) ( ) ) [year] => Dynarray (refcnt=1) ( [text] => 2013 [attributes] => Dynarray (refcnt=1) ( ) ) [format] => Dynarray (refcnt=1) ( [text] => Hardback [attributes] => Dynarray (refcnt=1) ( ) ) [attributes] => Dynarray (refcnt=1) ( [category] => COOKING ) ) ) )
https://www.lianja.com/doc/index.php/XQUERY_SELECT()
open database southwind use shippers cVar = xml_scatter()
https://www.lianja.com/doc/index.php/XML_SCATTER()
select company, street, town, state, zip from sales save as xml sales ? xmlcount("sales.xml") 25
https://www.lianja.com/doc/index.php/XMLCOUNT()
use prospect set xmlformat to recital ? xmlcreatedtd() .T.
https://www.lianja.com/doc/index.php/XMLCREATEDTD()
number = xmlfirst("sales.xml", target, trans, where, names, data) ? number 30
https://www.lianja.com/doc/index.php/XMLFIRST()
number = xmlnext(trans, where, names, data) ? number 30
https://www.lianja.com/doc/index.php/XMLNEXT()
? xmlvalidate("sales.xml") .T.
https://www.lianja.com/doc/index.php/XMLVALIDATE()
create table customer2; from xml cust.xml load
insert into products; from xml prices.xml
Export
use example copy to custxml xml
select employeeid, lastname, firstname; from employees into xml emp select employeeid, lastname, firstname; from employees save as xml emp
https://www.lianja.com/doc/index.php/Importing_and_Exporting_Data