Node parent = node.getParentNode();
Element g = dom.createElement( "mn-group-s" );
Element cur = dom.createElement( "mn-group" );
for(int i=0; i<n; i++ ){
Node child = node.getFirstChild();
node.removeChild( child );
if( digit[i] == ’x’ ){
if( cur.hasChildNodes() ){ g.appendChild( cur ); }
g.appendChild( child );
cur = dom.createElement( "mn-group" );
} else {
cur.appendChild( child );
} }
if( cur.hasChildNodes() ){ g.appendChild( cur ); }
parent.replaceChild( g, node );
-_-_-