如何从文件中读取html?

时间:2013-03-03 13:14:42

标签: java html file w3c-validation readfile

我有一个内容文件:

 <!DOCTYPE html> 
 <html>     
        <head>      
            <title>Hello, w3c validator!</title>    
        <head>
        <body>      
             <p>Hello again!</p>    
        </body> 
 </html>

如何用Java读取此文件并发送到validator-w3c?

1 个答案:

答案 0 :(得分:1)

您正在寻找的是Java程序:

  1. INPUT:HTML文件
  2. 阅读HTML文件
  3. 验证文件(w3c验证)
  4. 输出:验证输出
  5. 对于第1点和第2点,您可以在SO中为另一个帖子提供战利品:Reading entire html file to String?

    对于第3点,您可以查看Markup Validator Web Service API以获取有关如何联系w3c HTML验证器的规范,但这就是他们所说的:

    Note: Please be considerate in using this shared, free resource. 
    Consider Installing your own instance of the validator for smooth and fast operation. 
    Excessive use of the W3C Validation Service will be blocked.
    

    所以我的建议是阅读这篇文章,以便更好地了解您可以做什么,以及是否可以将其集成到Java Programa中:

    Installation information for the W3C Markup Validator