动态生成XML

                                                                                                                        动态生成XML

  使用Document动态生成XML:1.创建Document:1.实例化Document工厂:DocumentBuilderFactory

                                                                                                2.实例化Document构造器:DocumentBuilder

                                                                                                3.实例化DocumentDocument

                                                                                                4.创建标签:document.createElement();

                                                                                                5.创建属性:document.createAttribute();

                                                                                                6.建立关系:appendChild();

                                                   2.将Document保存到本地XML中: 1.实例化转换器工厂:TransFormerFactory

                                                                                                           2.实例化转换器:TransFormer

                                                                                                           3.设置来源:Source:DOMSource

                                                                                                           4.设置目的地:Result():StreamResult

                                                                                                           5.转换:transform()


dom4j:1.创建Document:1.使用DocumentHelper创建Document

                                                          2.添加标签:addElement("标签名")

                                                          3.添加属性:addAttribute("属性名","属性值")

                2. 将Document保存到本地XML中:1.实例化输出 格式:OutputFormat.createPrettyPrint()

                                                                          2. 指定输出文件路径:XMLWriter      

直接将对象集合,使用C标签展示到XML文件中:1.将对象集合保存到请求域中

                                                                         2.在jsp页面,使用C标签编译对象集合

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值