本文介绍了无法反序列化xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我得到的xml字符串如下所示。我是c#的新手。请帮助我使用序列化程序或反序列化从相同的xml字符串中获取值和arraylist。 <? xml version = 1.0 编码 = UTF-8 ? > < java version = 1.4.1.07 class = java.beans.XMLDecoder > < object class = java.util.HashMap > < void 方法 = 把 > < string > RES_ERROR_DESC < / string > < string > < / string > < / void > < void 方法 = put > < string > RES_VALUE_OUT < / string > < ob ject class = java.util.HashMap > < void 方法 = put > < string > 1 < / string > < object class = java.util.ArrayList > < void method = 添加 > < string > UMESH AGARWAL AGARWAL(MINOR)< / string > < / void > < void 方法 = 添加 > < string > & quot;& quot;& quot; 119 COTTON ST KOLKATA-700007 &安培; QUOT;&安培; QUOT;&安培; QUOT; < / string > < / void > < / object > < / void > < / object > < / void > < void 方法 = put > < 字符串 > RES_OUT < / string > < 字符串 > 成功< / string > < / void > < / object > < / java > 解决方案 您可以采取多种策略,但请记住,您正在翻译从Java到C#的对象,可能在结构上不同的对象。最糟糕的情况是你必须为没有映射到C#的Java对象编写自己的自定义解析器吗? 1.探索从Java到JSON的序列化,然后使用.NET的JSON类对JSON进行反序列化。 2.使用Microsoft的JLCA(Java语言转换助手)进行探索。注意:这是回头路,我从来没有用过它。[ ^ ]。 3. 2014年4月审核了将Java转换为C#的五种工具:> [ ^ ]。 我建议你在你的问题中添加序列化为你显示的XML的Java源代码 Hi,I am getting the xml string as given below. I am new in c#. Kindly help me to get the values and arraylist from the same xml string using serializer or deserialize.<?xml version="1.0" encoding="UTF-8"?> <java version="1.4.1.07" class="java.beans.XMLDecoder"> <object class="java.util.HashMap"> <void method="put"> <string>RES_ERROR_DESC</string> <string></string> </void> <void method="put"> <string>RES_VALUE_OUT</string> <object class="java.util.HashMap"> <void method="put"> <string>1</string> <object class="java.util.ArrayList"> <void method="add"> <string>UMESH AGARWAL AGARWAL (MINOR)</string> </void> <void method="add"> <string>&quot;&quot;&quot;119 COTTON ST KOLKATA-700007 &quot;&quot;&quot; </string> </void> </object> </void> </object> </void> <void method="put"> <string>RES_OUT</string> <string>SUCCESS</string> </void> </object></java> 解决方案 There are several strategies you could pursue, but, keep in mind that you are translating objects from Java to C#, objects that may be structurally different. Worst case is you have to write your own custom parser for Java objects that do not "map" to C# ?1. explore serializing from Java to JSON, and then use .NET's JSON classes to de-serialize the JSON.2. explore using the JLCA (Java Language Conversion Assistant) from Microsoft. Note: this goes "way back," and I've never used it.[^].3. There's an April 2014 review of five tools for converting Java to C# : >[^].I suggest you add to your question the Java source that was serialized into the XML you show. 这篇关于无法反序列化xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-15 01:51