XStream生成简单的XMl文件2

1、新建RequestInfo.java文件:

package com.saicfc.pmpf.resume.ccb.utils;

/**
 * 支付查询请求信息
 * @author lizhiyong
 * @version $Id: RequestInfo.java, v 0.1
		2014年7月24日 下午2:43:39 Exp $
 */
public class RequestInfo {

    public String REQUEST_SN;
    public String CUST_ID;
    public String USER_ID;
    public String PASSWORD;
    public String TX_CODE;
    public String LANGUAGE;
    public TxInfo TX_INFO;

    public RequestInfo(String rEQUEST_SN, String cUST_ID, String uSER_ID, String pASSWORD,
                       String tX_CODE, String lANGUAGE) {
        REQUEST_SN = rEQUEST_SN;
        CUST_ID = cUST_ID;
        USER_ID = uSER_ID;
        PASSWORD = pASSWORD;
        TX_CODE = tX_CODE;
        LANGUAGE = lANGUAGE;
    }

    public void setREQUEST_SN(String rEQUEST_SN) {
        REQUEST_SN = rEQUEST_SN;
    }

    public void setCUST_ID(String cUST_ID) {
        CUST_ID = cUST_ID;
    }

    public void setUSER_ID(String uSER_ID) {
        USER_ID = uSER_ID;
    }

    public void setPASSWORD(String pASSWORD) {
        PASSWORD = pASSWORD;
    }

    public void setTX_CODE(String tX_CODE) {
        TX_CODE = tX_CODE;
    }

    public void setLANGUAGE(String lANGUAGE) {
        LANGUAGE = lANGUAGE;
    }

    public void setTX_INFO(TxInfo tX_INFO) {
        TX_INFO = tX_INFO;
    }

}

2、新建TxInfo.java文件:

package com.saicfc.pmpf.resume.ccb.utils;

public class TxInfo {
    public String START;
    public String STARTHOUR;
    public String STARTMIN;
    public String END;
    public String ENDHOUR;
    public String ENDMIN;
    public String KIND;
    public String ORDER;
    public String ACCOUNT;
    public String DEXCEL;
    public String MONEY;
    public String NORDERBY;
    public String PAGE;
    public String POS_CODE;
    public String STATUS;

    public TxInfo(String sTART, String sTARTHOUR, String sTARTMIN, String eND, String eNDHOUR,
                  String eNDMIN, String kIND, String oRDER, String aCCOUNT, String dEXCEL,
                  String mONEY, String nORDERBY, String pAGE, String pOS_CODE, String sTATUS) {
        START = sTART;
        STARTHOUR = sTARTHOUR;
        STARTMIN = sTARTMIN;
        END = eND;
        ENDHOUR = eNDHOUR;
        ENDMIN = eNDMIN;
        KIND = kIND;
        ORDER = oRDER;
        ACCOUNT = aCCOUNT;
        DEXCEL = dEXCEL;
        MONEY = mONEY;
        this.NORDERBY = nORDERBY;
        PAGE = pAGE;
        POS_CODE = pOS_CODE;
        STATUS = sTATUS;
    }

    public void setSTART(String sTART) {
        START = sTART;
    }
    public void setSTARTHOUR(String sTARTHOUR) {
        STARTHOUR = sTARTHOUR;
    }
    public void setSTARTMIN(String sTARTMIN) {
        STARTMIN = sTARTMIN;
    }
    public void setEND(String eND) {
        END = eND;
    }
    public void setENDHOUR(String eNDHOUR) {
        ENDHOUR = eNDHOUR;
    }
    public void setENDMIN(String eNDMIN) {
        ENDMIN = eNDMIN;
    }
    public void setKIND(String kIND) {
        KIND = kIND;
    }
    public void setORDER(String oRDER) {
        ORDER = oRDER;
    }
    public void setACCOUNT(String aCCOUNT) {
        ACCOUNT = aCCOUNT;
    }
    public void setDEXCEL(String dEXCEL) {
        DEXCEL = dEXCEL;
    }
    public void setMONEY(String mONEY) {
        MONEY = mONEY;
    }
    public void setNORDERBY(String nORDERBY) {
        NORDERBY = nORDERBY;
    }
    public void setPAGE(String pAGE) {
        PAGE = pAGE;
    }
    public void setPOS_CODE(String pOS_CODE) {
        POS_CODE = pOS_CODE;
    }
    public void setSTATUS(String sTATUS) {
        STATUS = sTATUS;
    }

}

3、生成XML文件:

 XStream xStream = new XStream(new DomDriver("GB2312", new XmlFriendlyNameCoder("-_", "_")));

这一行是转化下划线

 XStream xStream = new XStream(new DomDriver("GB2312", new XmlFriendlyNameCoder("-_", "_")));
 xStream.alias("TX", RequestInfo.class);
 RequestInfo requestInfo = new RequestInfo(requestSn, custId, userId, password, txcode,
            language);
 requestInfo.setTX_INFO(new TxInfo(start, startHour, startMin, end, endHour, endMin, kind,
            order, account, dexcel, money, norderby, page, pos_code, status));
 String top = "<?xml version=\"1.0\" encoding=\"GB2312\" standalone=\"yes\" ?> \n";
 String xml = top + xStream.toXML(requestInfo);
时间: 2024-10-10 02:26:29

XStream生成简单的XMl文件2的相关文章

XStream生成简单的XMl文件

一.生成简单的XML文件: 1.新建ResumeToXml.java文件 package com.saicfc.pmpf.resume.bocom.utils.resume; /** * 把Java对象转化成xml * @author lizhiyong * @version $Id: RefundToXml.java, v 0.1 2014年6月5日 下午3:44:54 Exp $ */ @SuppressWarnings("unused") public class ResumeT

Android Button Maker(在线生成android shape xml文件的工具),真方便!

直接上地址:http://angrytools.com/android/button/ 使用起来超简单,如图: Android Button Maker is online tool to generate buttons code for Android Apps. Android API provide Drawable Resources where XML file defines geometric shape, including colors, border and gradien

asp.net简单读取xml文件信息

xml文件格式如下:     <?xml   version="1.0"   encoding="utf-8"?>         <userdata   createuser="false">         <dataconnection>             <server>localhost</server>             <uid>sa</uid

利用Pull生成和解析xml文件

解析xml的方式有很多,可以用dom,sax解析,但是在android平台上最常用是Pull解析,下面是简单的示例 <?xmlversion="1.0" encoding="UTF-8"?> <persons> <person id="18"> <name>allen</name> <age>36</age> </person> <person

C#生成空节点XML文件,自动换行问题

1.今天做项目时候生成XML文件,有些节点是为空节点,但是生成之后的节点自动换行了,网上百度了一下,大都是设置添加属性为xsi:nil="true"的空节点. http://www.acehat.com/kf/201503/78602.html 但是本人太笨不会用,于是又找到另一种方法,即为: 1 XmlWriterSettings settings = new XmlWriterSettings(); 2 settings.Indent = true; 3 settings.Inde

C#创建简单的Xml文件

/// <summary> /// 创建xml文件 /// </summary> /// <param name="xmlDoc">xml</param> /// <returns></returns> public string CreateXml(string xmlDoc) { string filePathName = string.Empty; try { if (Directory.Exists(XML

xml文件数据上报——根据模型生成对应的xml文件进行上报

1.引入命名空间:System.Xml 2.xml数据格式-xml存放位置 \XmlFiles\jgsj\AddAdminSuperItemInfo.xml <?xml version="1.0" encoding="utf-8" ?> <!--新增行政监管事项信息--> <Data> <AdminSuperItemInfo> <tenderProjectName>项目名称</tenderProjec

SSM 生成mapper中xml文件:未能解析映射资源:“文件嵌套异常

错误日记我就网上随便找个贴着: 错误一: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springf

webpack(二) 根据模板生成简单的html文件

(一)使用webpack 根据模板生成HTML,首先需要安装插件 html-webpack-plugin. 在工程文件夹安装插件 命令如下: npm install html-webpack-plugin --save-dev (二) 新建 webpack.config.js,名称可以更改,更改后 运行时,需指定 配置文件名称. 例如,配置文件名为 my.webpack.config.js, 则需要在package.json 文件中,在scripts 处添加如下代码: "scripts"