My Browser is "nokia browser" which cannot identify "Script" tag.
So I have to
(1)filter out "Script" tag and attributes of "Script" tag.
(2)filter out string which contain the string "Script".
then I have to visit all tags,make changes to tags' name and tags'
attributes.
recently,I find the following pattern is good.
Is it possible to translate a HTML file into a XHTML file
by the following pattern ?...@@.
--------------------------------------------------
Suggested Design
--------------------------------------------------
Parser parser = new Parser("http://www.yahoo.com");
NodeFilter filter=new NotFilter(new TagNameFilter("Script"));
parser.parse(filter);
for (NodeIterator i = parser.elements();i.hasMoreElements();) {
Node node = i.nextHTMLNode();
if (node instanceof StringNode) {
// Downcasting to StringNode
StringNode stringNode = (StringNode)node;
// Do whatever processing you want with the string node
System.out.println(stringNode.getText());
}
// Check for the node or tag that you want
if (node instanceof ...) {
// Downcast, and process
// recursively (nodes within nodes)
}
}
--------------------------------------------------
thank you
May goodness be with you all
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
regards:
I plan to use htmlparser 1.5 translate
a HTML file into a XHTML file.
My goal is as the link:
http://www.wretch.cc/album/show.php?i=otp&b=1&f=1107098054&p=0
sorry now cannot connect to it. =.=
My Browser is "nokia browser" which cannot identify "Script" tag.
So I have to
(1)filter out "Script" tag and attributes of "Script" tag.
(2)filter out string which contain the string "Script".
then I have to visit all tags,make changes to tags' name and tags'
attributes.
recently,I find the following pattern is good.
Is it possible to translate a HTML file into a XHTML file
by the following pattern ?...@@.
--------------------------------------------------
Suggested Design
--------------------------------------------------
Parser parser = new Parser("http://www.yahoo.com");
NodeFilter filter=new NotFilter(new TagNameFilter("Script"));
parser.parse(filter);
for (NodeIterator i = parser.elements();i.hasMoreElements();) {
Node node = i.nextHTMLNode();
if (node instanceof StringNode) {
// Downcasting to StringNode
StringNode stringNode = (StringNode)node;
// Do whatever processing you want with the string node
System.out.println(stringNode.getText());
}
// Check for the node or tag that you want
if (node instanceof ...) {
// Downcast, and process
// recursively (nodes within nodes)
}
}
--------------------------------------------------
thank you
May goodness be with you all
That should work.
regards:
Dear Derrick Oswald,
thank you for your patient reply and instructions.^^
I will check again.
thank you
May goodness be with you all