问题描述
我有使用一些古老的XStream保存的旧XML文件。
现在我正在使用最新的XStream,并尝试加载数据。 它成功加载了日期和整数,但是字符串为空。
param = (Param) xstream.fromXML(strQueueParam);
其中strQueueParam是以下内容:
<com.company.Params>
<capturedDate class="org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl" resolves-to="org.apache.xerces.jaxp.datatype.SerializedXMLGregorianCalendar">
<lexicalValue>2020-10-13T10:03:00.000+02:00</lexicalValue>
</capturedDate>
<capturedUsername>
<name serialization="custom">
<javax.xml.namespace.QName>
<default>
<localPart>Captured_Username</localPart>
<namespaceURI>http://schemas.datacontract.org/2004/07/RuleEngineLibrary</namespaceURI>
<prefix></prefix>
</default>
</javax.xml.namespace.QName>
</name>
<declaredType>java.lang.String</declaredType>
<scope>org.datacontract.schemas._2004._07.rulesenginelibrary.Param</scope>
<value class="string">Bob Example</value>
<nil>false</nil>
</capturedUsername>
<capturedInt>5</capturedInt>
</com.company.Params>
好,所以我意识到这些{name / declaredType / scope / value / nil}是JAXBElement的字段。
所以我认为发生的事情是,旧代码没有使用jaxb绑定,因此所有类都包含JAXBElement<String>
而不是String
。
但是,除非我拥有错误生成的旧Param文件,否则现在我无法反序列化此废话XML。
好吧,我可能必须手动转换XML。我现在只是在自言自语。我不希望得到答案。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)