Parsing xml file with xpath and xquery using eXist-db -


i need fetch <title> element following xml using xquery (i'm using exist-db).

<?xml-stylesheet href="shakes.xsl" type="text/xsl"?> <!--!doctype play public "-//play//en" "play.dtd"--> <clinicaldocument xmlns="urn:hl7-org:v3">     <play>         <title>the tragedy of hamlet, prince of denmark</title>     </play> </clinicaldocument > 

when try xquery below not getting expected output.

xquery version "3.0";  doc("/db/apps/demo/data/hamlet.xml")/clinicaldocument/play/title 

i think problem related xmlns attribute present in <clinicaldocument> tag:

<clinicaldocument xmlns="urn:hl7-org:v3"> 

how can modify xquery retrieve desired xml element?

declare prefix mapped xml default namespace, , use prefix reference elements in namespace, :

declare namespace d = "urn:hl7-org:v3"; doc("/db/apps/demo/data/hamlet.xml")/d:clinicaldocument/d:play/d:title 

tested here : http://www.xpathtester.com/xquery/a88f300bbeacdbd846d7aec887d48a0b


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -