Advertisement
Guest User

Fixed

a guest
Mar 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1.     public void tagRmvlC2(TagNode currentNode,String tag,TagNode previousNode) {
  2.         if(currentNode==null) {
  3.             return;
  4.         }
  5.         else if(currentNode.tag.equals(tag)) {
  6.             if(previousNode!=null) {
  7.                 if(currentNode.firstChild==null) {//When THE PICKED TAG HAS NO CHILD
  8.                     if(previousNode.sibling!= null && previousNode.sibling.equals(currentNode)) {
  9.                         previousNode.sibling=currentNode.sibling;
  10.                         currentNode=previousNode.sibling;
  11.                     }
  12.                     else {//the previousNode is the parent
  13.                         previousNode.firstChild=currentNode.sibling;
  14.                         currentNode=previousNode.firstChild;
  15.                     }
  16.                 }
  17.                 else {
  18.                     if(previousNode.sibling!= null && previousNode.sibling.equals(currentNode)) {
  19.                         TagNode tempNode=currentNode.sibling;
  20.                         TagNode tempNodeTwo = null;
  21.                         previousNode.sibling=currentNode.firstChild;
  22.                         tempNodeTwo= previousNode.sibling;
  23.                         while(tempNodeTwo!=null) {
  24.                             if(tempNodeTwo.tag.equals("li")) {
  25.                                 tempNodeTwo.tag="p";
  26.                             }
  27.                             tempNodeTwo=tempNodeTwo.sibling;
  28.                         }
  29.                         tempNodeTwo= previousNode.sibling;
  30.                         while(tempNodeTwo.sibling!=null) {
  31.                             tempNodeTwo=tempNodeTwo.sibling;
  32.                         }
  33.                         tempNodeTwo.sibling=tempNode;
  34.                         currentNode=previousNode.sibling;
  35.                     }
  36.                     else {//the previousNode is the PARENT SO THE CHILD OF THE
  37.                         TagNode tempNode=currentNode.sibling;
  38.                         TagNode tempNodeTwo = null;
  39.                         previousNode.firstChild=currentNode.firstChild;
  40.                         tempNodeTwo= previousNode.firstChild;
  41.                         while(tempNodeTwo!=null) {
  42.                             if(tempNodeTwo.tag.equals("li")) {
  43.                                 tempNodeTwo.tag="p";
  44.                             }
  45.                             tempNodeTwo=tempNodeTwo.sibling;
  46.                         }
  47.                         tempNodeTwo= previousNode.firstChild;
  48.                         while(tempNodeTwo.sibling!=null) {
  49.                             tempNodeTwo=tempNodeTwo.sibling;
  50.                         }
  51.                         tempNodeTwo.sibling=tempNode;
  52.                         currentNode= previousNode.firstChild;
  53.                     }
  54.                 }
  55.             }
  56.         }
  57.             tagRmvlC2(currentNode.firstChild,tag,currentNode);
  58.             tagRmvlC2(currentNode.sibling,tag,currentNode);
  59.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement