Open main menu

Wikibooks β

XQuery/Extracting data from XHTML files

< XQuery


To perform an XQuery on XHTML files that use the XHTML namespace.


We will start our XQuery by adding the default namespace for XHTML.

   declare default element namespace "";

Sample Source CodeEdit

Assume that you have an well-formed XHTML file in the file /db/text/index.xhtml

xquery version "1.0";
declare default element namespace "";
declare option exist:serialize "method=html media-type=text/html indent=yes";
let $doc := doc('/db/test/index.xhtml')
let $body := $doc/html/body/*
      <title>Replace Head</title>