Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在改型android中使用简单xml转换器反序列化html转义字符_Android_Xml_Retrofit_Converters_Simple Xml Converter - Fatal编程技术网

在改型android中使用简单xml转换器反序列化html转义字符

在改型android中使用简单xml转换器反序列化html转义字符,android,xml,retrofit,converters,simple-xml-converter,Android,Xml,Retrofit,Converters,Simple Xml Converter,如何在改型android中使用简单的xml转换器将响应体的xml内部标记中的html转义字符反序列化到POJO类中 <?xml version="1.0" encoding="utf-8"?> <sample> <outer> &lt;test&gt;data<&lt;/test>&gt; </outer> </sample> 试验数据 这应该可以 @Root public

如何在改型android中使用简单的xml转换器将响应体的xml内部标记中的html转义字符反序列化到POJO类中

<?xml version="1.0" encoding="utf-8"?>
<sample>
  <outer>
    &lt;test&gt;data<&lt;/test>&gt;
  </outer>
</sample>

试验数据
这应该可以

@Root
public class Sample {
    @Element
    Outer outer;
}

public class Outer {
    @Text
    String text;

    public Test test;

    public Xml(@Text String text) {
        Serializer serializer = new Persister();
        try {
            example = serializer.read(Test.class, text);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

public class Test {

    @Element
    public String data;
}

您是否尝试过将
xml
转换为
POJO
?是的,简单的xml转换器,因为普通xml中的转换器工厂被转换。但有时转义字符会出现在xmlI的内部标记之间。它返回null。您确定它可以与simple XML2.7.1一起使用吗?请检查您的输入,我认为它的格式可能不正确。正确的一个应该是这样的:
testdata/test
Here,它为我编译并正确工作:给你:。此外,它在Android和plain上也同样有效Java@VineethKuttipurathkottayodan我认为
@元素对象读取应该这样做