Storing application data
Application can store vital operational data and retrieve it. Data is stored in an xml structure and can be attached to a user or to a folder. Use the following methods to store data
To store data an application should pass the following arguments :
-
xpath - xpath is the path that marks the place inside the xml where the tag should be insert, replaced or removed. When inserting a new tag the FULL xpath should be specified. more about xpath at http://www.w3schools.com/xpath.
-
tag - The name of the tag to be inserted or replaced.
-
value - The value of the tag.
-
attributes - pairs of name/value the represents the attributes of the tag.
Example 1 : simple use
Adding last_used tag :
method |
users.setAppData |
xpath |
/mydata/last_used |
tag |
last_used |
value |
8/5/2008 2:08:55 PM |
...
<mydata>
<last_used>8/5/2008 2:08:55 PM</last_used>
</mydata>
...
Replacing last_used value with a new one
method |
users.setAppData |
xpath |
/mydata/last_used |
tag |
last_used |
value |
8/5/2008 4:18:12 PM |
...
<mydata>
<last_used>8/5/2008 4:18:12 PM</last_used>
</mydata>
...
Removing last_used tag
method |
users.setAppData |
xpath |
/mydata/last_used |
tag |
|
value |
|
...
<mydata />
...
Example 2 : advance use
Adding user record :
method |
users.setAppData |
xpath |
/mydata/users/user[@id='1'] |
tag |
user |
value |
oren |
attributes |
id=1,type='normal' |
...
<mydata>
<users>
<user id='1' type='normal'>oren</user>
</users>
</mydata>
...
Adding another user record :
method |
users.setAppData |
xpath |
/mydata/users/user[@id='2'] |
tag |
user |
value |
iris |
attributes |
id=2,type='normal' |
...
<mydata>
<users>
<user id='1' type='normal'>oren</user>
<user id='2' type='normal'>iris</user>
</users>
</mydata>
...
Replacing value in first user record :
method |
users.setAppData |
xpath |
/mydata/users/user[@id='1'] |
tag |
user |
value |
ronie |
attributes |
id=1,type='normal' |
...
<mydata>
<users>
<user id='1' type='normal'>ronie</user>
<user id='2' type='normal'>iris</user>
</users>
</mydata>
...
Removing first user record :
method |
users.setAppData |
xpath |
/mydata/users/user[@id='1'] |
tag |
|
value |
|
attributes |
|
...
<mydata>
<users>
<user id='2' type='normal'>iris</user>
</users>
</mydata>
...