TestXml.java
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.agent.xml;
import com.agent.xml.common.ContentXml;
import com.agent.xml.common.XmlHead;
import com.agent.xml.common.XmlUtil;
import com.agent.xml.shunt.ShuntXml;
import com.agent.xml.shunt.ShuntXmlBody;
/**
* Created by cohesion on 2017/4/24.
*/
public class TestXml {
public static void main(String[] args) {
objectToXml();
}
public static void objectToXml(){
ShuntXmlBody body = new ShuntXmlBody();
XmlHead head = new XmlHead();
head.setMessageID("1.1");
head.setFunctionCode("1.1");
head.setMessageType("1.1");
head.setVersion("1.0");
body.setHead(head);
ShuntXml shuntXml = new ShuntXml();
shuntXml.setBorderTransportMeans(null);
shuntXml.setConsignment(null);
ContentXml contentXml = new ContentXml();
//contentXml.setContent("NNNNN");
shuntXml.setAdditionalInformation(contentXml);
body.setDeclaration(shuntXml);
String xml = XmlUtil.convertToXml(body);
System.out.println(xml);
}
}