如何创建/更新/在运行时加载一个HTML文件 [英] How to create/update/load a HTML file at runtime

查看:115
本文介绍了如何创建/更新/在运行时加载一个HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建并在运行时打开HTML文件。

 < HTML>
      <身体GT;
        <表格名称=家的方法=POST行动=''>
          <输入ID ='标题类型=隐藏值=先生NAME =标题/>
          <输入ID ='名称'类型=隐藏值=巴拉NAME ='名称'/>
           。
           。
           。
         < /形式GT;
         < SCRIPT LANGUAGE =JavaScript的'>
            // Java脚本
         < / SCRIPT>
      < /身体GT;
    < / HTML>
 

在上面的格式,我需要在运行时更新字段。更新后,我想在我的Andr​​oid应用程序中打开该HTML文件。

更新: 我知道我们能箱子HTML文件,如下图所示。

 公共静态字符串createHTML(研究研究){
    字符串格式=
            < HTML>中+
            <身体GT; +
            <表格名称=家的方法=POST行动=''>中+
            <输入ID ='标题类型=隐藏值=%d的名称=标题/>中+
            。
            。
            。
            。
            < /身体GT; +
            < / HTML>中;
    返回的String.Format(格式,study.title,study.name ...);
}
 

但我手淫知道是否有任何其他方式来创建像使用的 XmlSerializer的 谢谢!

解决方案
  

如何创建HTML文件。

  1. 开启文件
  2. 包含HTML写文本字符
  3. 关闭文件

如果您需要更多的细节,甲骨文Java教程,对基本的Java构建的经验教训,并就如何做简单的文件I / O。


有做这种在不同环境下的东西(如Web服务)的其他更优雅的方式,但如果这个总和就是你需要做的,然后... ...保持它的简单。


  

...是否有任何其他的方法来创建HTML文件,就像使用XmlSerializer的创建XML文件。

而不是HTML。你可以这样通过创建XHTML。

说了这么多,建设HTML或XHTML的方式听起来像一个可怜的想法。由此产生的code是既不可读或效率......用绳子串联或基于模板的方法相比。

(试试看......)

I need to create and open an HTML file at runtime.

    <html>
      <body>
        <form name="Home" method="POST" action='' >
          <input id='Title' type='hidden' value="Mr" name='Title'/>
          <input id='Name' type='hidden' value="bala" name='Name'/>
           .
           .
           .
         </form>
         <script language='javascript'>
            //java script
         </script>
      </body>
    </html>

In above format, i need to update value field at runtime. After updating I want to open this html file within my android application.

Update: I know we can crate HTML file like below..

public static String createHTML(Study study) {
    String format =
            "<html>" +
            "<body>" +
            "<form name="Home" method="POST" action='' >" +
            "<input id='Title' type='hidden' value='%d' name='Title'/>" +
            .
            .
            .
            .
            "   </body>" +
            "</html>";
    return String.format(format, study.title, study.name...);
}

but i wank to know is there any other way to create HTML file like creating XML file using XmlSerializer Thanks!

解决方案

How to create html file.

  1. Open file
  2. Write text characters comprising the HTML
  3. Close file

If you need more details, the Oracle Java Tutorial has lessons on basic Java constructs, and on how to do simple file I/O.


There are other more "elegant" ways of doing this kind of thing in different contexts (e.g. in a web service) but if this the sum total of what you need to do, then ... keep it simple.


... is there any other way to create HTML file like creating XML file using XmlSerializer.

Not HTML. You could create XHTML that way through.

Having said that, constructing HTML or XHTML that way sounds like a poor idea. The resulting code would be neither readable or efficient ... compared with string concatenation or template-based approaches.

(Try it and see ...)

这篇关于如何创建/更新/在运行时加载一个HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆