xml operation
package demo.oath ;
import org.jdom.* ;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class AccountHelper
{
public final static String XML_ACCOUNT_ROOT = "DB" ;
public final static String XML_ACCOUNT_ACCOUNT = "Account" ;
public final static String XML_ACCOUNT_NAME = "name" ;
public final static String XML_ACCOUNT_INDEX = "index" ;
public final static String XML_ACCOUNT_PASSWORD = "passwd" ;
public final static String XML_ACCOUNT_COUNTER = "counter" ;
public final static String XML_ACCOUNT_LOCKED = "locked" ;
public final static String XML_ACCOUNT_COST = "cost";
public final static String XML_TTY_COUNTER = "tryCounter";
public static void main(String[] args) {
Element e=new Element("Account");
System.out.println(AccountHelper.Element2Account(e));
}
/**
* parst element to Account
* @param e
* @return
*/
public static Account Element2Account ( Element e )
{
System.out.println("AccountHelper.XML_TTY_COUNTER="+AccountHelper.XML_TTY_COUNTER);
String index = e.getChildText ( AccountHelper.XML_ACCOUNT_INDEX ) ;
String userName = e.getChildText ( AccountHelper.XML_ACCOUNT_NAME ) ;
String passwd = e.getChildText ( AccountHelper.XML_ACCOUNT_PASSWORD ) ;
String cost = e.getChildText(AccountHelper.XML_ACCOUNT_COST);
String tryCounter = e.getChildText(AccountHelper.XML_TTY_COUNTER);
System.out.println("tryCounter="+tryCounter);
System.out.println("-------------------------------------cost-------------------------");
System.out.println(cost);
System.out.println("--------------------------------------end");
String counter = e.getChildText ( AccountHelper.XML_ACCOUNT_COUNTER ) ;
int counterI=0
相关文档:
基于dom4j的XML格式转化类
package com.lixi.util;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.dom4j.Document;
import org.do ......
写XML:
protected void btnSave_Click(object sender, EventArgs e)
{
//权限判断
XmlTextWriter xmlw = new XmlTextWriter(Server.MapPath("~\\") + "FriendLink.xml", Encoding.Ge ......
XML How to Program
Beginning Xml Databases
Beginning XSLT and XPath Transforming XML Documents and Data
ASP.NET 2.0 XML
XML 手册 4th Edition
XML Schema Complete Reference
......
这篇文章被转载的次数最多,其实代码简陋得我自己都看不下去。只不过发表这篇文章时很多人需要这个功能。
这几天写个数据库查询分析器,要用到XML记录用户注册的数据库连接地址、端口等信息,最开始想用java ......