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