Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I pass data to XQuery and XPath

Status
Not open for further replies.

estafford

Programmer
Sep 5, 2002
22
0
0
US
1. Can I pass data to XQuery and XPath from an application?

If yes...

2. Is it possible to build a query in XQuery and XPath from the data passed from an application.

I am trying to develop an application using Flash with XML.
I want to query the XML file using data passed from flash without using any web server technology.

Thanks
 
Although Flash supports XML, it is *very* limited in what the object can actually do with it. AFAIK, there are no methods in Flash's XML object that allow you to build xquery or xpath functions and select nodes from the XML document.

I had a go at writing something similar to MSXML's selectSingleNode in ActionScript and if you want to take a look I'll be happy to supply the code, otherwise there are a couple of things on the net which may allow you to simulate xpath querys on XML data.

As an aside, and just for your info, XML in flash was incredibly slow for large XML documents. (I dont know if subsequent versions are different). It seems that Macromedia in there wisdom decided not to thread the parser that the XML object used to read in the document, therefore producing a noticible pause if dealing with files larger than about 1mb.


Just let me know if you want those Actionscripts, I have them to hand but they aren't finished completely and have holes in their functionality (although the code that's there works). I didnt get around to implementing functions as I couldnt be bothered :)


Hope this helps,


Matt
 
Thanks Flumpy,
Any help would be appreciated. I'd love to take a look at your samples. I have not used XML, XPath, or XQuery before. It seems the best choice for this project.

Would I be able to pass an XQuery to the XML doc using flash's XML.sendandload method?

As I understand it, this would send xml data to the xml doc.
So can I send the data as a query using XQuery? Or am I completely wrong?

As a note, I also read that originaly, the Flash XML parser was writen in actionscript but because of the slow performance, it was rewriten in C++. There is also another XML parser available for Flash called XMLNitro available at
This is a personal project. More for a learning experience. Thanks for the help.
 
I found a link to my thingy on actionscript.org.. its the second one of the two that are there.



If you've got any probs with it just let me know. its not perfect and there are prolly better things out there but anyhew.


On the send and load note, it looks like sendAndLoad will send XML to a script or cgi program on the server which can then reply in xml back to flash. You could write an xml document containing an xpath expression to execute and send that to a script on the server which then returns the xml produced from the XPath statement... but its a bit of a round trip for small documents and you've still got the problem of extracting the XML from the returned document with the fiddly Flash XML Object...

For example I suppose (and i'm only guessing here) that you could construct an XML document to do the query:

<xpath-query document='mydoc.xml'>
//node[nodeatt='hello']/*
</xpath-query>

which you could send to a script on the server which takes this query and performs it on the specified document. Then the script could return something like this:

<xpath-result>
<node nodeatt='hello'>my contents 1</node>
<node nodeatt='hello'>my contents 2</node>
<node nodeatt='hello'>...</node>
<node nodeatt='hello'>my contents x</node>
</xpath-result>

which is then (by the magic of sendAndLoad) put into the XML object by flash.

This is an interesting concept which never crossed my mind before... let me know how you get on developing it :)


Matt Corby.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top