格式:我们取ContainerEvent的数据
- <?xml version="1.0" ?>
- <Master xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <OnBoardDate>20130225T06:00:00</OnBoardDate>
- <PortOfLoading>CNDLC</PortOfLoading>
- <ETA>20130317T17:45:00</ETA>
- <ATA xsi:nil="true" />
- <ManifestQuantity>3720</ManifestQuantity>
- <Containers>
- <Container>
- <ContainerNo>OOLU7246170</ContainerNo>
- <Weight>18048.000 KGS</Weight>
- <Quantity>3720 Carton</Quantity>
- <CurrentStatus>Container Returned to Carrier</CurrentStatus>
- <Date>20130327T23:58:00</Date>
- <LocationName>Equipment For Sale/offhire</LocationName>
- <EDICenterRecevedDate xsi:nil="true" />
- <SEQ xsi:nil="true" />
- <events>
- <ContainerEvent>
- <Time>20130317T17:45:00</Time>
- <EventDesc>Vessel Arrived</EventDesc>
- <Location>Tacoma, Tacoma, Pierce, Washington, United States</Location>
- <Mode />
- <Facility>Port of Discharge</Facility>
- <Remarks />
- </ContainerEvent>
- <ContainerEvent>
- <Time>20130304T08:00:00</Time>
- <EventDesc>Vessel Departed</EventDesc>
- <Location>Busan, Busan, South Korea</Location>
- <Mode />
- <Facility>Port of Transshipment</Facility>
- <Remarks />
- </ContainerEvent>
- <ContainerEvent>
- <Time>20130219T12:04:00</Time>
- <EventDesc>Container Picked Up</EventDesc>
- <Location>Yungtong Depot, Dalian, Liaoning, China</Location>
- <Mode>Truck</Mode>
- <Facility />
- <Remarks>Empty Container</Remarks>
- </ContainerEvent>
- </events>
- </Container>
- </Containers>
- </Master>
- public JsonResult GetXMLData()
- {
- try
- {
- string xmlstr="....";
- StringReader reader = new StringReader(xmlstr);
- IList<ContainerEvent> products = new List<ContainerEvent>();
- var serializer = new XmlSerializer(typeof(Master));
- var items = (Master)serializer.Deserialize(reader);
- return Json(items.cts.ct.events.Items);
- }
- catch (Exception ) {
- return Json("查询错误!");
- }
- }
model:
- [Serializable]
- public class ContainerEvent
- {
- //[XmlAttribute(AttributeName = "Time")]
- public DateTime Time { get; set; }
- //[XmlAttribute(AttributeName = "EventDesc")]
- public string EventDesc { get; set; }
- //[XmlAttribute(AttributeName = "Location")]
- public string Location { get; set; }
- // [XmlAttribute(AttributeName = "Mode")]
- public string Mode { get; set; }
- // [XmlAttribute(AttributeName = "Facility")]
- public string Facility { get; set; }
- // [XmlAttribute(AttributeName = "Remarks")]
- public string Remarks { get; set; }
- }
- [XmlRoot("Master")] //XmlRoot必须描述根元素
- public class Master
- {
- [XmlElement("Containers")]
- public Containers cts { get; set; }
- }
- public class Containers
- {
- [XmlElement("Container")]
- public Container ct { get; set; }
- }
- public class Container
- {
- [XmlElement("events")]
- public events events { get; set; }
- }
- public class events
- {
- [XmlElement("ContainerEvent")]
- public ContainerEvent[] Items { get; set; }
- }
http://www.bdqn.cn/news/201312/12290.shtml
http://blog.youkuaiyun.com/bdstjk/article/details/7210742
http://blog.youkuaiyun.com/bdstjk/article/details/7211086
格式:我们取ContainerEvent的数据
- <?xml version="1.0" ?>
- <Master xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <OnBoardDate>20130225T06:00:00</OnBoardDate>
- <PortOfLoading>CNDLC</PortOfLoading>
- <ETA>20130317T17:45:00</ETA>
- <ATA xsi:nil="true" />
- <ManifestQuantity>3720</ManifestQuantity>
- <Containers>
- <Container>
- <ContainerNo>OOLU7246170</ContainerNo>
- <Weight>18048.000 KGS</Weight>
- <Quantity>3720 Carton</Quantity>
- <CurrentStatus>Container Returned to Carrier</CurrentStatus>
- <Date>20130327T23:58:00</Date>
- <LocationName>Equipment For Sale/offhire</LocationName>
- <EDICenterRecevedDate xsi:nil="true" />
- <SEQ xsi:nil="true" />
- <events>
- <ContainerEvent>
- <Time>20130317T17:45:00</Time>
- <EventDesc>Vessel Arrived</EventDesc>
- <Location>Tacoma, Tacoma, Pierce, Washington, United States</Location>
- <Mode />
- <Facility>Port of Discharge</Facility>
- <Remarks />
- </ContainerEvent>
- <ContainerEvent>
- <Time>20130304T08:00:00</Time>
- <EventDesc>Vessel Departed</EventDesc>
- <Location>Busan, Busan, South Korea</Location>
- <Mode />
- <Facility>Port of Transshipment</Facility>
- <Remarks />
- </ContainerEvent>
- <ContainerEvent>
- <Time>20130219T12:04:00</Time>
- <EventDesc>Container Picked Up</EventDesc>
- <Location>Yungtong Depot, Dalian, Liaoning, China</Location>
- <Mode>Truck</Mode>
- <Facility />
- <Remarks>Empty Container</Remarks>
- </ContainerEvent>
- </events>
- </Container>
- </Containers>
- </Master>
- public JsonResult GetXMLData()
- {
- try
- {
- string xmlstr="....";
- StringReader reader = new StringReader(xmlstr);
- IList<ContainerEvent> products = new List<ContainerEvent>();
- var serializer = new XmlSerializer(typeof(Master));
- var items = (Master)serializer.Deserialize(reader);
- return Json(items.cts.ct.events.Items);
- }
- catch (Exception ) {
- return Json("查询错误!");
- }
- }
model:
- [Serializable]
- public class ContainerEvent
- {
- //[XmlAttribute(AttributeName = "Time")]
- public DateTime Time { get; set; }
- //[XmlAttribute(AttributeName = "EventDesc")]
- public string EventDesc { get; set; }
- //[XmlAttribute(AttributeName = "Location")]
- public string Location { get; set; }
- // [XmlAttribute(AttributeName = "Mode")]
- public string Mode { get; set; }
- // [XmlAttribute(AttributeName = "Facility")]
- public string Facility { get; set; }
- // [XmlAttribute(AttributeName = "Remarks")]
- public string Remarks { get; set; }
- }
- [XmlRoot("Master")] //XmlRoot必须描述根元素
- public class Master
- {
- [XmlElement("Containers")]
- public Containers cts { get; set; }
- }
- public class Containers
- {
- [XmlElement("Container")]
- public Container ct { get; set; }
- }
- public class Container
- {
- [XmlElement("events")]
- public events events { get; set; }
- }
- public class events
- {
- [XmlElement("ContainerEvent")]
- public ContainerEvent[] Items { get; set; }
- }
http://www.bdqn.cn/news/201312/12290.shtml
http://blog.youkuaiyun.com/bdstjk/article/details/7210742
http://blog.youkuaiyun.com/bdstjk/article/details/7211086