关于xml文件转为java实体类,如果不带命名空间 “<m:”,用jaxb的unmarshaller方法,还有注解@XmlRootElement 等方法可以转成功,但是xml包含了"<m:"前缀(命名空间)就有问题。网上找了好久也没能解决。还请高手帮我看下。谢谢
xml代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--周期抄表Response-->
<ResponseMessage xmlns="http://iec.ch/TC57/2011/schema/message" xmlns:m="http://iec.ch/TC57/2011/ MeterReadings#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Payload>
<m:MeterReadings>
<m:MeterReading>
<m:Meter>
<m:mRID>3dc53ee5-777e-50b4-8699-a1c224f45f3d</m:mRID>
<Names>
<name>1</name>
<NameType>
<name>MeterType</name>
</NameType>
</Names>
</m:Meter>
<m:Readings>
<m:timeStamp>2015-06-1T00:00:00+04:30</m:timeStamp>
<m:value>2.6</m:value>
<m:ReadingType ref="13.0.0.1.1.1.12.0.0.0.0.1.0.0.0.3.72.0"/>
<m:timePeriod>
<m:end>2015-06-1T00:00:00+04:30</m:end>
<m:start>2015-05-1T00:00:00+04:30</m:start>
</m:timePeriod>
</m:Readings>
</m:MeterReading>
</m:MeterReadings>
</Payload>
</ResponseMessage>