void removeNode(Node *n) { Node *parent; Node *prev; Node *next; parent = parentNode(n); if (!parent) return; prev = previousSibling(n); next = nextSibling(n); if (prev) { set_nextSibling(prev, next); } else { if (parent) { set_firstChild(parent, next); } } if (next) { set_previousSibling(next, prev); } else { if (parent) { set_lastChild(parent, prev); } } /* Delete attributes */ Delattr(n,"parentNode"); Delattr(n,"nextSibling"); Delattr(n,"prevSibling"); }
void appendChild(Node *node, Node *chd) { Node *lc; if (!chd) return; lc = lastChild(node); if (!lc) { set_firstChild(node,chd); } else { set_nextSibling(lc,chd); set_previousSibling(chd,lc); } while (chd) { lc = chd; set_parentNode(chd,node); chd = nextSibling(chd); } set_lastChild(node,lc); }
void deleteNode(Node *n) { Node *parent; Node *prev; Node *next; parent = parentNode(n); prev = previousSibling(n); next = nextSibling(n); if (prev) { set_nextSibling(prev,next); } else { if (parent) { set_firstChild(parent,next); } } if (next) { set_previousSibling(next,prev); } else { if (parent) { set_lastChild(parent,prev); } } }