CDATA反序列化非常有效。但是我应该如何配置此映射:
class MyData: XMLMappable {
var nodeName: String!
var cdataValue: String?
...
func mapping(map: XMLMap) {
cdataValue <- map.attributes["cdataValue"]
}
}
当我打电话给toXMLString()
时:
let myData = MyData()
myData.cdataValue = "actualValue"
print(myData.toXMLString())
最终获得这样的东西:
<cdataValue><![CDATA[ actualValue ]]></cdataValue>