在xstream解析期间删除xml标签?
这是我使用 xstream 生成的 Xml,
<Request>
<MSISDN>9900624233</MSISDN>
<TRANSID>123456</TRANSID>
</Request>
我想删除该
<Request></Request>
选项卡,只需要
<MSISDN>9900624233</MSISDN>
<TRANSID>123456</TRANSID>
这么多,
我的类是
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;
}
}
并且 xstream 映射是
xStream.alias("Request", XmlRequest.class);
xStream.aliasField("MSISDN",XmlRequest.class,"msisdn");
xStream.aliasField("TRANSID", XmlRequest.class, "tranid");
那么我该怎么做? 你能帮助我吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 String.replace 函数
,如 xml.replace("Request")
它将起作用
use String.replace function
like xml.replace("Request")
it will work