Created
July 21, 2013 15:26
-
-
Save arolle/6048870 to your computer and use it in GitHub Desktop.
XQuery Snippet that makes XML available to Javascript. To be used with @BaseXdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: | |
: Snippet that makes the XML from the variable $xml available | |
: to Javascript. | |
:) | |
let $xml := <p>my text</p> | |
! serialize(., | |
<output:serialization-parameters> | |
<output:method value="xml"/> | |
<output:item-separator value=""/> | |
</output:serialization-parameters> | |
) | |
! replace(.,"\n","") | |
return | |
<script type="text/javascript"> | |
var data = '{$xml}'; | |
<![CDATA[ | |
// creates div-Element containing the XML as stored in $xml | |
window.onload = function() { | |
var div = document.createElement('div'); | |
div.innerHTML = data; | |
document.body.appendChild(div); | |
}; | |
]]> | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment