简体   繁体   中英

De serialize html escape characters using simple xml converter in retrofit android

How can we deserialize html escape characters in inner tags of xml of a response body to be saved in POJO classes using simple xml converter in retrofit android?

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

This should do it

@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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM