EnumXMLAttributes
File management function.
The EnumXMLAttributes function retrieves the attribute names and attribute values for the specified XML node. Not available in WinTask Lite.
Syntax
EnumXMLAttributes(<filename>,<XML_path>,<attribute_name_array>,<value_array>)
or
ret=EnumXMLAttributes(<filename>,<XML_path>,<attribute_name_array>,<value_array>)
Parameters
<filename>, string, name of the XML file where to add/modify the attribute.
<XML_path>, string, list of node descriptors separated by the \ character to go where the attribute is. The string is not case-sensitive.The structure of such a path is:
tagname[attributename1='value']
The tagnames are strings without double quotes, they cannot contain spaces or reserved characters.
The attribute names are strings without double quotes, OR it can be the reserved keyword <text> or the reserved keyword <index>. <text> is used to specify the node inner text, <index> is used to specify the node index (first one starts at 1) when more nodes with the same tag and attributes exist within the same parent. Several attributes can be listed with the syntax tagname[attributename1='value1', attributename2='value2']
Examples:
If the XML file contains:
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
the <XML_path> can be "bookstore\book[genre='autobiography']" or "bookstore\book[publicationdate='1981']" or "bookstore\book[publicationdate='1981',genre='autobiography']"<attribute_name_array>, array of strings. The content of the cells beginning with element 0 returns each attribute name under the specified XML node.
<value_array>, array of strings. The content of the cells beginning with element 0 returns the value for the corresponding attribute.
Return value
Ret, numeric return code. When the function is successfully executed, ret returns the number of attributes for the specified XML path, otherwise use this return code for Error Handling. The error codes are :
-27
The XML file could not be opened
-90
Internal error (COM error when invoking XML COM)
-99
Invalid parameters
-110
Invalid XML path
-112
Index too big
See also
Example
XML file:
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
dim children$(100)
dim name$(100)
dim value$(100)
file$ = "c:\program files\wintask\scripts\sample.xml"
ret = EnumXMLAttributes(file$, "bookstore\book[<index>=2]", name$(), value$())
'ret returns the number of attributes under bookstore\book\[<index>=2] XML node
msgbox(ret)
' Displays the first attribute name and its value
msgbox(name$(0) + "=" + value$(0))