XMLMapper:如何序列化CDATA包装的值?

时间:2018-07-04 11:50:44

标签: swift xmlmapper

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>

0 个答案:

没有答案