Menu

translate a HTML file into a XHTML file

Help
2005-02-06
2013-04-27
  • mikeliu1976

    mikeliu1976 - 2005-02-06

    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

     
    • Derrick Oswald

      Derrick Oswald - 2005-02-06

      That should work.

       
    • mikeliu1976

      mikeliu1976 - 2005-02-07

      regards:
      Dear Derrick Oswald,

      thank you for your patient reply and instructions.^^
      I will check again.

      thank you 
      May goodness be with you all

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.