Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void tagRmvlC2(TagNode currentNode,String tag,TagNode previousNode) {
- if(currentNode==null) {
- return;
- }
- else if(currentNode.tag.equals(tag)) {
- if(previousNode!=null) {
- if(currentNode.firstChild==null) {//When THE PICKED TAG HAS NO CHILD
- if(previousNode.sibling!= null && previousNode.sibling.equals(currentNode)) {
- previousNode.sibling=currentNode.sibling;
- currentNode=previousNode.sibling;
- }
- else {//the previousNode is the parent
- previousNode.firstChild=currentNode.sibling;
- currentNode=previousNode.firstChild;
- }
- }
- else {
- if(previousNode.sibling!= null && previousNode.sibling.equals(currentNode)) {
- TagNode tempNode=currentNode.sibling;
- TagNode tempNodeTwo = null;
- previousNode.sibling=currentNode.firstChild;
- tempNodeTwo= previousNode.sibling;
- while(tempNodeTwo!=null) {
- if(tempNodeTwo.tag.equals("li")) {
- tempNodeTwo.tag="p";
- }
- tempNodeTwo=tempNodeTwo.sibling;
- }
- tempNodeTwo= previousNode.sibling;
- while(tempNodeTwo.sibling!=null) {
- tempNodeTwo=tempNodeTwo.sibling;
- }
- tempNodeTwo.sibling=tempNode;
- currentNode=previousNode.sibling;
- }
- else {//the previousNode is the PARENT SO THE CHILD OF THE
- TagNode tempNode=currentNode.sibling;
- TagNode tempNodeTwo = null;
- previousNode.firstChild=currentNode.firstChild;
- tempNodeTwo= previousNode.firstChild;
- while(tempNodeTwo!=null) {
- if(tempNodeTwo.tag.equals("li")) {
- tempNodeTwo.tag="p";
- }
- tempNodeTwo=tempNodeTwo.sibling;
- }
- tempNodeTwo= previousNode.firstChild;
- while(tempNodeTwo.sibling!=null) {
- tempNodeTwo=tempNodeTwo.sibling;
- }
- tempNodeTwo.sibling=tempNode;
- currentNode= previousNode.firstChild;
- }
- }
- }
- }
- tagRmvlC2(currentNode.firstChild,tag,currentNode);
- tagRmvlC2(currentNode.sibling,tag,currentNode);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement