@XMLHASXPATH[["filename",],xpath] : Returns 1 if the xpath exists in the XML file, or 0 if it doesn't.

 

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

 

@XMLHASXPATH may be used to check if an xpath exists before setting it via @XMLXPATH.

 

The XML parser in TCC implements a subset of the XML XPath specification, allowing you to point to specific elements in the XML documents. The xpath 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:

'name'

A particular element name

name[i]

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

[i]

The i-th subelement of the current element

[last()]

The last subelement of the current element

[last()-i]

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

name[@attrname="attrvalue"]

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

..

The parent of the current element

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>

 

Return 1 if the XPath exists:

 

ECHO %@XMLHASXPATH["bookstore.xml",/bookstore]

1

 

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