@XMLGETATTR[["filename",],attributename]: renvoie la valeur de l'attribut spécifié.

 

Si vous ne spécifiez pas de nom de fichier, @XMLGETATTR utilisera le fichier précédemment ouvert par @XMLOPEN.

 

Vous devez définir le XPath avant d'appeler @XMLGETATTR.

 

Exemple :

 

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

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

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

ENDDO

SET c=%@XMLCLOSE[]

 

L'exécution de bookstore.btm produit :

 

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

 

Erreurs XML :

 

101 Index d'attribut invalide

102 Aucun attribut disponible

103 Index d'espace de noms incorrect

104 Aucun espace de noms disponible

105 Index d'élément incorrect

106 Aucun élément disponible

107 L'attribut n'existe pas

201 Balise d'élément déséquilibrée

202 Préfixe d'élément inconnu (espace de noms introuvable)

203 Préfixe d'attribut inconnu (espace de noms introuvable)

204 Balisage XML non valide

205 État final invalide pour l'analyseur

206 Le document contient des éléments déséquilibrés

207 XPath invalide

208 Aucun enfant de ce type

209 L'élément supérieur ne correspond pas au début du chemin

210 L'arbre DOM n'est pas disponible

302 Impossible d'ouvrir le fichier

401 Un XML invalide serait généré

402 Un nom XML non valide a été spécifié