datapointer-basics.lzx
<canvas debug="true" width="100%">
<dataset name="ds" src="./shareddata/contacts_full.xml"/>
<datapointer name="dp"/>
<window title="Datapointer usage">
<simplelayout/>
<text fontstyle="bold" fontsize="15">Outputs of these buttons should display in the Debugger window</text>
<button text="Show value of first name of the first <person/> node">
<handler name="onclick">
dp.setAttribute("xpath","ds:/addressbook/contacts/person[1]");
//dp.setXPath("ds:/addressbook/contacts/person[1]");
Debug.debug("%w", dp.getNodeAttribute('firstname'));
</handler>
</button>
<button text="Show the full name of the owner of the address book.">
<handler name="onclick">
dp.setAttribute("xpath","ds:/addressbook/metainformation/addressbookowner[1]/");
Debug.debug("%w %w", dp.getNodeAttribute('firstname'), dp.getNodeAttribute('lastname'));
</handler>
</button>
<button text="Show total of <person/> nodes?">
<handler name="onclick">
dp.setAttribute("xpath","ds:/addressbook/contacts");
Debug.debug("%w", dp.getNodeCount());
</handler>
</button>
<button text="Show the value of the lastname of the 2nd node">
<handler name="onclick">
dp.setAttribute("xpath","ds:/addressbook/contacts/person[2]");
Debug.debug("%w", dp.getNodeAttribute('firstname'));
</handler>
</button>
<button text="Capitalize the firstname of the 2nd node">
<handler name="onclick">
dp.setAttribute("xpath","ds:/addressbook/contacts/person[2]");
Debug.debug("BEFORE %w", dp.getNodeAttribute('firstname'));
dp.setNodeAttribute('firstname',dp.getNodeAttribute('firstname').toUpperCase()) ;
Debug.debug("AFTER %w", dp.getNodeAttribute('firstname'));
</handler>
</button>
</window>
</canvas>
Cross References
Named Instances
- <datapointer name="dp">
- <dataset name="ds">