E4X: No L♥ve for siblings

Since AS 3's XML access lacks completely on the sibling axis, i decided to roll my own wire for that:

public class XMLUtils
{
public function XMLUtils():void
{

}
//Alle Geschwister eines Knotens
public static function siblings(node:XML):XMLList
{
return node.parent().children();
}
//nächstes Geschwister
public static function nextSibling(node:XML):XML
{
return node.parent().*[node.childIndex() + 1];
}
//voriges Geschwister
public static function previousSibling(node:XML):XML
{
return node.parent().*[node.childIndex() -1];
}
}


Keine Kommentare:

Kommentar veröffentlichen

You might as well leave a comment on this matter: