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
相关文档:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Data;
using System.Dat ......
红色字体为主要代码
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 ......
IsolatedStorageFile:包含文件和数据的独立存储区
dataset数据存储到本地xml文档,代码处理如下
public static void WriteDataToXML(DataSet dataset, string dataname)
{
try
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly(); / ......
Definition comparer class,
class ItemComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return x.Attribute("Name").Value == x.Attribute("Name").Value;
}
public int GetHashCode(XElement obj)
......
from:http://www.xland.com.cn/article/7/81/0804/28778.htm
本类实现:
数据库信息导出:word,excel,json,xml,sql
数据库恢复:从sql,从文件
具体用法:
首先新建测试用数据库mytest,然后在里面建张表
PHP代码:
以下是代码片段:
--
-- 表的结构 `test`
--
CREATE TABLE `test` (
`id ......