@XMLPUTATTR[name,namespaceURI,value] : Writes an XML attribute
@XMLPUTATTR writes an XML attribute on the currently opened XML element. It must be called right after calling @XMLSTARTELEMENT and before any calls to @XMLPUTSTRING, @XMLPUTCOMMENT, or @XMLPUTRAW. The file must have been opened with a previous @XMLOPEN.
If name is a local name without a prefix, the class will automatically introduce a new xmlns="NamespaceURI" attribute if necessary.
If name is in the form prefix:local, then class will automatically introduce a new xmlns:prefix="NamespaceURI" as necessary.
Certain attribute names will be handled in special ways by this method. If name is "xmlns" or uses the "xmlns" prefix, the attribute will be interpreted as a namespace declaration, regardless of the value of NamespaceURI. Similarly, any attribute using the "xml" prefix will be interpreted as a special attribute (like "xml:lang") and NamespaceURI will be ignored.
Returns 0 on success, or an XML error on failure.
Example:
To create this XML named books.xml:
<book xmlns='urn:loc.gov:books' xmlns:isbn='urn:ISBN:0-395-36341-6'>
<title>Cheaper by the Dozen</title>
<isbn:number>1568491379</isbn:number>
</book>
Use the code:
echo %@xmlcreate[books.xml]
echo %@xmlstartelement[book,urn:loc.gov:books]
echo %@xmlputattr[xmlns:isbn,"",urn:ISBN:0-395-36341-6]
echo %@xmlputelement[title,urn:loc.gov:books,Cheaper by the Dozen]
echo %@xmlputelement[isbn:number,urn:ISBN:0-395-36341-6,1568491379);
echo %@xmlendelement[]
echo %@xmlclose[]
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