Establish the value of an attribute of the element node. The node can be passed as argument or as attribute.
 

1 dom.element.setAttribute

<dom.element.setAttribute
    name='name'
    attr='attr'
>
    <node /> ?
</dom.element.setAttribute>
Example

Establish the value of an attribute of an element.

Copy
<xsql-script name='dom_element_setAttribute'>

    <body>
        <set name='root'>
            <dom.parse><file name='c:\tmp\data.xml' type='absolute' /></dom.parse>
        </set>

        <!-- It is situated in the text node which contains the text hello -->
        <set name='elem_text'>
            <dom.element.getFirstChildElement><root /></dom.element.getFirstChildElement>
        </set>

        <!-- Return: green -->
        <println>
            <dom.element.getAttribute attr='color'>
                <elem_text/>
            </dom.element.getAttribute>
        </println>


            <dom.element.setAttribute attr='color' value='orange'>
                <elem_text/>
            </dom.element.setAttribute>

        <!-- Return: orange -->
        <println>
            <dom.element.getAttribute attr='color'>
                <elem_text/>
            </dom.element.getAttribute>
        </println>

    </body>
</xsql-script>