Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.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 使用SimpleXML使用HTML转义部分反序列化XML_Android_Xml_Retrofit_Simple Framework_Html Escape Characters - Fatal编程技术网

Android 使用SimpleXML使用HTML转义部分反序列化XML

Android 使用SimpleXML使用HTML转义部分反序列化XML,android,xml,retrofit,simple-framework,html-escape-characters,Android,Xml,Retrofit,Simple Framework,Html Escape Characters,我有一个XML,看起来像这样: <xml> &lt;example&gt;&lt;string&gt;test&lt;/string&gt;&lt;/example&gt; </xml> 好的,我想我明白了 SimpleXML将转义序列解析为@Text,我可以在中使用它,并在该构造函数中创建另一个Persister实例,该实例读取该序列。以下是问题中示例的代码: @Root public class Xml

我有一个XML,看起来像这样:

<xml>
&lt;example&gt;&lt;string&gt;test&lt;/string&gt;&lt;/example&gt;
</xml>
好的,我想我明白了

SimpleXML将转义序列解析为
@Text
,我可以在中使用它,并在该构造函数中创建另一个
Persister
实例,该实例读取该序列。以下是问题中示例的代码:

@Root
public class Xml {
    @Text
    String text;

    public Example example;

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

public class Example {

    @Element
    public String string;
}

有趣的是,我不需要恢复转义字符,SimpleXML为我做了这件事。

你能看看吗。我在这里被绊倒了。我们可以用简单的xml阅读一个空白的xml标签吗;我想获得“读取”状态的存在;2040以下的xml在解析其他详细信息及其对象时总是出错:140TestCTOTestTest
@Root
public class Xml {
    @Text
    String text;

    public Example example;

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

public class Example {

    @Element
    public String string;
}