Hello
i am trying to replace a <object> tag with an <img> tag reading an
html file and sending the html to an editor.
It was working great unless the object tag was inside of a <div> or
nested inside some other tag.
So on the mailing list i found a recursive function example that i
have modified. It is working kindof.
As i am going thru the nodes if it is not an <object> tag and am just
adding that node.toHtml() to the StringBuffer Object that i am passing
to the editor.
if it is an object and a flash object i need to replace the object tag
with an image tag.
I am finding the object tag and replacing it ok, but as i traverse the
document, i am not adding everything to the StringBuffer Object. Like
tables in tables are not being added, and probably other tags within
tags.
if anyone can see something obvious that i am doing something wrong.
thanks
StringBuffer retStrBuf();
public void parse (Parser parser, NodeIterator i) throws ParserException {
Node node;
Node subnode;
if( i == null ) {
i = parser.elements();
}
while( i.hasMoreNodes() ){
node = i.nextNode();
NodeList nl=null;
if(node != null) {
nl = node.getChildren();
if ( nl != null ){
if
(nl.extractAllNodesThatMatch(objFilter,false).size() > 0) {
NodeIterator x = nl.elements();
while ( x.hasMoreNodes() ){
subnode = x.nextNode();
if ( subnode instanceof ObjectTag){
ObjectTag ObjTag = (ObjectTag) subnode;
if ( ObjTag.getAttribute("classid") != null &&
ObjTag.getAttribute("classid").equals("clsid:d27cdb6e-ae6d-11cf-96b8-444553540000")
){
//remove of verbose stuff
ImageTag it = new ImageTag();
//remove of somemore verbose stuff
//System.out.println("--->"+it.toHtml());
retStrBuf.append(it.toHtml());
}
}else{
//System.out.println("--->"+subnode.toHtml());
retStrBuf.append(subnode.toHtml());
}
}
}else{
parse(parser,nl.elements());
}
}else{
//System.out.println(node.toHtml());
retStrBuf.append(node.toHtml());
}
}//end of null node
}//end of while
}//end of function
|