The tag <stack.pop> removes the last object stored in the stack and returns its value. The stack can be indicated via the attribute name or passing it as argument.

1 stack.pop

<stack.pop name='name'>
    <stack /> ?
</stack.pop>
Example

Initialize the stack of execution with two values and obtain them through the tag stack.pop.

Copy
<xsql-script name='pop_test'>
    <body>

        <stack name='stack1'><number>10</number><string>hello</string></stack>
        
        <!-- Now in the stack there is only the value <number>10</number>. -->
        <set name='a'><stack.pop name='stack1' /></set>

        <println><a/></println>
        <!-- hello -->

        <!-- Extraction of the object that is in the top of the stack -->
        <set name='b'><stack.pop><stack1/></stack.pop></set>

        <println><b/></println>
        <!-- 10 -->

    </body>
</xsql-script>
Example

Travel a stack and obtain its values.

Copy
<xsql-script name='pop_test'>
   <body>
       <stack name='stack1' />
       <stack.push name='stack1'>
           <number>10</number>
       </stack.push>
       <stack.push name='stack1'>
           <number>20</number>
       </stack.push>
       <stack.push name='stack1'>
           <number>30</number>
       </stack.push>
       <println>The stack is: <stack1 /></println>
       <while>
           <expr><not><stack.empty name='stack1'/></not></expr>
           <do>
               <println>Removed <stack.pop name='stack1' /> from stack</println>
           </do>
       </while>
   </body>

</xsql-script>