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
相关文档:
测试用的xml文件
<?xml version="1.0" encoding="UTF-8"?>
<schools>
<school id='111'>测试学校</school>
<school id='222'>测试学校22
<class id='2.1'>测试班级222</class>
</school>
</schools>
测试用的JavaScript代码
$().ready(function ......
function getkeyvalue(s_keyname,s_keystr)
s_keybegin="<"+s_keyname+">"
s_keyend="</"+s_keyname+">"
s_i_begin=instr(s_keystr,s_keybegin)
s_i_end=instr(s_keystr,s_keyend)
if s_i_end<=s_i_begin+len(s_keybegin) then
getkeyvalue=""
exit function
else
getkeyvalue=mid(s_k ......
首先我们给出一段示例程序:
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.dom ......
private
NodeList root(
final
String url ,
final
String str){
NodeList root =
null
;
try
{
InputSource is=
new
InputSource(
new
InputStreamReader(
new
UR ......
作者: J. Andrew Schafer
这篇文章假设你对 XML, XSLT, 和 C# 熟悉
下载这篇文章的源代码: XMLC.exe (76KB)
译者说明:这篇文章是很早以前就发表了,它提供的源代码是基于 VS.net 测试版(RTM 和 Beta 2)的。
摘要
C# 允许开发人员在源代码中插入XML注释,这在多人协作开发的时候显得特别有用。 ......