Reputation: 189786
Is there a way to test whether an XML element is empty using e4x?
e.g. if I have an element <foo />
, I want to return true, but if I have another element that has any attributes, child elements, or text, I want to return false.
Upvotes: 0
Views: 1153
Reputation: 189786
I just slogged through the ECMA-357 v2 spec on e4x; the methods for XML nodes are listed in section 13.4.4, and there are no useful isXXX()
or hasXXX()
methods for this test; the simplest way to do it seems to be the following:
function isEmptyNode(node){
return node.children().length() == 0 && node.attributes().length() == 0;
}
Upvotes: 2