dom4j 读写xml文件
首先我们给出一段示例程序:
import
java.io.File;
import
java.io.FileWriter;
import
java.util.Iterator;
import
org.dom4j.Document;
import
org.dom4j.DocumentHelper;
import
org.dom4j.Element;
import
org.dom4j.io.OutputFormat;
import
org.dom4j.io.SAXReader;
import
org.dom4j.io.XMLWriter;
public
class
DOM4JTest
{
/** */
/**
*/
/** */
/**
*/
/** */
/**
*/
/** */
/**
* DOM4J读写XML示例
*
*
@param
args
*
@throws
Exception
*/
public
static
void
main(String[] args)
{
try
{
XMLWriter writer
=
null
;
//
声明写XML的对象
SAXReader reader
=
new
SAXReader();
OutputFormat format
=
OutputFormat.createPrettyPrint();
format.setEncoding(
"
GBK
"
);
//
设置XML文件的编码格式
String filePath
=
"
d:\\student.xml
"
;
File file
=
new
File(filePath);
if
(file.exi
相关文档:
得到一个需要处理的XMl
private string GetSaveItem()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<menuCollection/>");
foreach (TreeNode node in trvAccessRight.CheckedNodes)
{
if (node != trvAccess ......
下载 dom4j-1.6.1.jar。
1: package org.zzp.common.xml.dom4j;
2:
3: import java.io.FileWriter;
4: import java.io.IOException;
5: import org.dom4j.Document;
6: import org.dom4j.DocumentHelper;
7: import org.dom4j.Element;
8: import org.dom4j.io.OutputFormat;
9: impor ......
Introduction to XML and XML With Java
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xer ......
using System;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
// 添加引用 -> .NET -> Microsoft.Office.Interop.Excel(2003->11.0, 2007->12.0)
namespace WinFormTable
{
& ......