@XMLCLOSE[] : Close an XML file previously opened by @XMLOPEN.

 

@XMLCLOSE returns 0 on success, or an XML error if it fails.

 

Example:

 

Bookstore.xml :

 

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

<bookstore>

<book>

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

   <price>29.99</price>

</book>

<book>

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

   <price>39.95</price>

</book>

<book>

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

   <price>14.99</price>

</book>

<book>

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

   <price>49.99</price>

</book>

</bookstore>

 

Bookstore.btm:

 

@ECHO OFF

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

ENDDO

SET c=%@XMLCLOSE[]

 

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