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
Ïà¹ØÎĵµ£º
ÓÃjava´´½¨XmlµÄ4´óÀࣺ
Element£º½ÚµãÀà
AttributeÊôÐÔÀà
Document£ºÖ¸µÄ¾ÍÊÇÎĵµÀà
XMLOutput£ºÊä³öÀà
´ËÀàÊÇÓÃjava½¨Á¢Ò»¸öxmlÎļþ
public class TestJdom {
//´´½¨XML£¨Ä£ÐÍ£©dom
public static void main(String[] args) {
  ......
XML ×÷ΪÊý¾ÝÔ´µÄʵÀý£¨TESTED£©
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" preinitialize="preInit()" fontSize="12" height="500">
<mx:Script>
  ......
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 ......
Ò»£ºSpringÖеļ¸ÖÖÈÝÆ÷¶¼Ö§³ÖʹÓÃxml×°Åäbean£¬°üÀ¨£º
XmlBeanFactory £¬
ClassPathXmlApplicationContext £¬
FileSystemXmlApplicationContext £¬
XmlWebApplicationContext
¼ÓÔØÕâЩÈÝÆ÷µÄÅäÖÃÎļþµÄxmlÓÐһϼ¸ÖÖ³£¼ûµ ......
public sealed class XmlHelper
{
public static void Serialize<T>(T obj,string fileName)
{
TextWriter writer = new StreamWriter(fileName);
try
{
XmlSerializer ser = new XmlSerializer(typeof(T));
......