This is about deleting a node from XML in Flex. Here our XML is assigned to a variable, treeXml.
delete treeXml.node.(@label=="abc")[0];
Above code deletes the child (node) which is having the attribute label equal to 'abc'. Notice '[0]' at the end of the statement. After this, treeXml would be;
Thanks,
Danuka.
var treeXml: XML = <root>
<node label="abc">
<node label="Page"></node>
<node label="Business"></node>
<node label="Application"></node>
<node label="Loyalty"></node>
</node>
<node label="def">
<node label="Page"></node>
<node label="Business"></node>
<node label="Application"></node>
<node label="Loyalty"></node>
</node>
</root>
Suppose we need to delete the node with label 'abc'. The way to do it is;delete treeXml.node.(@label=="abc")[0];
Above code deletes the child (node) which is having the attribute label equal to 'abc'. Notice '[0]' at the end of the statement. After this, treeXml would be;
<root>
<node label="def">
<node label="Page"></node>
<node label="Business"></node>
<node label="Application"></node>
<node label="Loyalty"></node>
</node>
</root>
Thanks,
Danuka.
No comments:
Post a Comment