New Feature for modify XML with java script

Next major release will support this feature (replace the Modify element wizard) , so user can write java script to perform complex modification. A variable named node is created automatic. It represented the selected node in dialog box.
Here is a example://get id attribute from first child node named 'span'
var nid=node.span['@id'];
//above call is same as: var nid=node.getChild('span')['@id'];
//delete first child node
//insert text before node
The node object will provide lots of function(Detail can be found here). Most of get methods are W3C API like... and additional support:
  • For get child node : node.childName is the same as node.getChild('childName') unless the childName is the same as any supported function.
  • For get attribute value : node['@attrName'] is the same as node.getAttribute('attrName')
Basic rules for modification: 1) All node text/data are evaluated as original value.
For example://if node['@attr']='789'
//try to set @id=@attr
//node['@id'] will be '789' not '123'
2) If a node is modified several times, high priority modification will overwrite others.
For example://remove a node
//below call will not take effect, because remove() conflict with setOuterHTML();
If you have any suggesion, please feedback.

No comments:

Post a Comment