@XMLGETATTR[["filename",],attributename] : Returns the value of the specified attribute.


If you do not specify a filename, @XMLGETATTR will use the file previously opened by @XMLOPEN.


You must set the XPath before calling @XMLGETATTR.




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 Language=%@XMLGETATTR[lang]

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

       ECHO %Title (in %Language) costs only %Price




Running bookstore.btm outputs:


Harry Potter (in jap) costs only 29.99

Learning XML (in eng) costs only 39.95

Day Watch (in ger) costs only 14.99

Winston Churchill: An Autobiography (in eng) 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