DOM4J生成XML文档
public int createXMLFile(String filename) {
int returnValue = 0;
Document document = DocumentHelper.createDocument(); //生成Document,用于管理XML文档
Element booksElement = document.addElement("books"); //添加根节点
booksElement.addComment("This is a test for dom4j, holen, 2004.9.11"); //添加注释
Element bookElement = booksElement.addElement("book"); //在跟节点books下添加一个book子节点
bookElement.addAttribute("show", "yes"); //为bookElement添加属性,并制定属性的值
Element titleElement = bookElement.addElement("title"); //为bookElement节点添加一个title子节点
titleElement.setText("Dom4j Tutorials"); //为title子节点设置文本节点内容
try {
XMLWriter writer = new XMLWriter(new FileWriter(new File(filename)));
writer.write(document); //普通格式,比较不美观
OutputFormat format =null;
// format=OutputFormat.createPrettyPrint(); //美化格式,读取后美化显示
// writer = new XMLWriter( System.out, format );
// writer.write( document );
// format = OutputFormat.createCompactFormat(); //缩减格式,读取后缩减显示
// writer = new XMLWriter( System.out, format );
// writer.write( document );
writer.close();
return
相关文档:
红色字体为主要代码
jsp页面中
<script language="javascript">
function updateDB(operate){
var objDom=new ActiveXObject("msxml.DomDocument");
var objRoot=objDom.createElement("All");
objDom.appendChild(objRoot);
var k=document.ge ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
create procedure [dbo].[MachiningPayedGetListByCondition]
@CustomerName varchar(50),
@CustomerPhone varchar(50),
@PactNumber varchar(50),
@Ispay bit
as
begin
set nocount on;
SELECT
dp.ID as 'MachiningPayed/@ID',
&nbs ......
data.xml
<?xml version="1.0" encoding="UTF-8"?>
<Items>
<Item ASIN="0446355453"
Author="Sidney Sheldon"
Manufacturer="Warner Books"
ProductGroup="Book"
Title="Master of the Game"/>
<Item ASIN=" ......