@XMLXPATH[["filename"],path] : XML XPath query. The arguments are:


filename - name of XML file

path - one or more element accessors separated by a /.


If you don't specify a filename (which *must* be in double quotes), @XMLXPATH will use the XML file previously opened by @XMLOPEN.


To return an attribute, preface the attribute name with an @.


The path is a series of one or more element accessors separated by '/'. The path can be absolute (starting with '/') or relative to the current XPath location. The following are possible values for an element accessor:


A particular element name


The i-th subelement of the current element with the given name


The i-th subelement of the current element


The last subelement of the current element


The subelement located at the last location minus i in the current element


The subelement containing a particular value for a given attribute (supports single AND double quotes)


The parent of the current element




Bookstore.xml :


<?xml version="1.0" encoding="ISO-8859-1"?>



   <title lang="jap">Harry Potter</title>




   <title lang="eng">Learning XML</title>




   <title lang="ger">Day Watch</title>




   <title lang="eng">Winston Churchill: An Autobiography</title>








SET a=%@XMLOPEN[bookstore.xml]

SET b=%@XMLNODES[/bookstore]

DO i = 1 to %b

       SET Title= %@XMLXPATH[/bookstore/book[%i]/title]

       SET Price= %@XMLXPATH[/bookstore/book[%i]/price]

       ECHO %Title ` costs only ` %Price




Running bookstore.btm outputs:


Harry Potter  costs only   29.99

Learning XML  costs only   39.95

Day Watch  costs only   14.99

Winston Churchill: An Autobiography  costs only   49.99


XML Errors:


101 Invalid attribute index

102 No attributes available

103 Invalid namespace index

104 No namespaces available

105 Invalid element index

106 No elements available

107 Attribute does not exist

201 Unbalanced element tag

202 Unknown element prefix (can't find namespace)

203 Unknown attribute prefix (can't find namespace)

204 Invalid XML markup

205 Invalid end state for parser

206 Document contains unbalanced elements

207 Invalid XPath

208 No such child

209 Top element does not match start of path

210 DOM tree unavailable

302 Can't open file

401 Invalid XML would be generated

402 An invalid XML name has been specified