Search code examples
javaxmlxstream

Remove xml tag during xstream parsing?


This is My Xml generated using xstream

<Request>
<MSISDN>9900624233</MSISDN>
<TRANSID>123456</TRANSID>
</Request>

i want to remove that

<Request></Request>

tab and only need

<MSISDN>9900624233</MSISDN>
<TRANSID>123456</TRANSID>

this much,

my class is

package com.sixdee.imsivlr.bean;

import java.io.Serializable;

public class XmlRequest implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = 1L;
public String msisdn;
public String tranid;


public String getMsisdn() {
    return msisdn;
}
public String getTranid() {
    return tranid;
}
public void setMsisdn(String msisdn) {
    this.msisdn = msisdn;
}
public void setTranid(String tranid) {
    this.tranid = tranid;
}

}

and xstream mapping is

xStream.alias("Request", XmlRequest.class);
xStream.aliasField("MSISDN",XmlRequest.class,"msisdn");
xStream.aliasField("TRANSID", XmlRequest.class, "tranid");

So how can i do that ?? Can u help Me ?


Solution

  • use String.replace function

    like xml.replace("Request")

    it will work