How to remove hyperlink tag using java

Hello all !!!

I have developed a text editor and also included the function to add a hyperlink. But i dont know how to remove the hyperlink <a href> tag from the generated html using java.Please help me out with any function that can implement remove hyperlink.

Eagerly waiting for the reply.

[319 byte] By [navsa] at [2007-11-27 7:57:45]
# 1

> Hello all !!!

> I have developed a text editor

> and also included the function to add a hyperlink.

> But i dont know how to remove the hyperlink <a href>

> tag from the generated html using java.Please help

> me out with any function that can implement remove

> hyperlink.

You don't give us a whole lot of information. I'm assuming that this isn't javascript.

petes1234a at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...
# 2
my html code looks like <a href=" http://www.google.com">Go for a google search </a>l;now i want to remove this hyperlink using java.can you help me out with that?
navsa at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...
# 3

> my html code looks like

> <a href="http://www.google.com">Go for a google

> search </a>l;

>

> now i want to remove this hyperlink using java.

>can you help me out with that?

no, what does your java code look like? or again, are you talking about javascript?

petes1234a at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...
# 4

if(htmlTag.toString().equals(HTML.Tag.A.toString()))

{

SimpleAttributeSet sasText = null;

for(int i = caretOffset; i < caretOffset + internalTextLength; i++)

{

parentTextPane.select(i, i + 1);

sasText = new SimpleAttributeSet(parentTextPane.getCharacterAttributes());

Enumeration attribEntries1 = sasText.getAttributeNames();

while(attribEntries1.hasMoreElements() && currentAnchor.equals("http://"))

{

Object entryKey = attribEntries1.nextElement();

Object entryValue = sasText.getAttribute(entryKey);

if(entryKey.toString().equals(HTML.Tag.A.toString()))

{

if(entryValue instanceof SimpleAttributeSet)

{

Enumeration subAttributes = ((SimpleAttributeSet)entryValue).getAttributeNames();

while(subAttributes.hasMoreElements() && currentAnchor.equals("http://"))

{

Object subKey = subAttributes.nextElement();

if(subKey.toString().toLowerCase().equals("href"))

{

anchor = ((SimpleAttributeSet)entryValue).getAttribute(subKey).toString();

Character firstCharacter = anchor.charAt(1);

if(firstCharacter=='j')

{

int size=anchor.length();

int index1 = anchor.indexOf("'")+1;

String value1=anchor.substring(index1, size);

int secondIndex = value1.indexOf("'");

currentAnchor = value1.substring(0, secondIndex);

String str1 = value1.substring(secondIndex+1);

String str2 = str1.substring(69);

String status = str1.substring(14,15);

if(status.equalsIgnoreCase("1"))

{

toolStatus=true;

}

System.out.println("print toolbar Status "+status);

width=str2.substring(0, str2.indexOf(","));

height =str2.substring(str2.indexOf("=")+1, str2.indexOf(")")-1);

newWindow=true;

}

else{

currentAnchor=anchor;

}

break;

}

}

}

}

}

if(!currentAnchor.equals("http://")) { break; }

}

}

parentTextPane.select(caretOffset, caretOffset + internalTextLength);

SimpleAttributeSet sasTag = new SimpleAttributeSet();

SimpleAttributeSet sasAttr = new SimpleAttributeSet();

if(htmlTag.toString().equals(HTML.Tag.A.toString()))

{

if(!htmlAttribs.containsKey("href"))

{

UserInputAnchorDialog uidInput = new UserInputAnchorDialog(parentEkit, Translatrix.getTranslationString("AnchorDialogTitle"), true, currentAnchor,height,width,newWindow,toolStatus);

String newAnchor = uidInput.getInputText();

String value = uidInput.getTarget();

uidInput.dispose();

if(newAnchor != null)

{

htmlAttribs2.put("href",newAnchor);

parentEkit.jmiRemoveAnchor.setEnabled(true);

}

else

{

parentEkit.repaint();

parentEkit.jmiRemoveAnchor.setEnabled(false);

return;

}

}

}

The UserInputAnchorDialogue is my class for the UI of setting a hyperl

navsa at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...
# 5
please format your code.otherwise you may need a regex solution (where is uncle_alice when you need him?).
petes1234a at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...
# 6
Don't drag me into this yet! It's so rare to see someone trying to mamipulate HTML with HTML-specific tools, I don't want to discourage the OP. ^_^ But I'm also not going to try to read that unformatted mess; @navs, please try again, this time using [code][/code] tags.
uncle_alicea at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...
# 7
hey....can u tell me how can i get the <a> tag for a particular selected text using java.
navsa at 2007-7-12 19:39:39 > top of Java-index,Java Essentials,Java Programming...