ios - 如何从 KISSXML 中删除 xml 声明?

标签 ios libxml2 kissxml

我正在使用 KissXML (iOS) 创建一个 xml 文档。一切都很好,但是当我想使用 XMLString 方法将 DOM 写入 NSString 时,输出的 xml 字符串包含 xml 声明( <?xml version="1.0" encoding="UTF-8" ?> )。有没有办法从生成的 xml 字符串中删除此声明?

谢谢

最佳答案

我发现,您可以在 rootElement 上调用 XMLString 方法,而不是在 DDXMLDocument 对象上调用 XMLString 方法,这样: 而不是(其中 xml 是 DDXMLDocument):

NSString* str=[xml XMLString];

使用这个:

NSString* str=[[xml rootElement] XMLString];

结果是一个没有 xml 声明的完整 xml 文档。

关于ios - 如何从 KISSXML 中删除 xml 声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27229446/

相关文章:

ios - CocoaPods 0.37.2 和 KissXML 5.0 的问题

ios - 重新签名的 IPA 未通过 codesign 正确验证

c - MSYS : Error c compiler cannot create executables

ios - PushViewController 在解雇 ViewController 后不会推送

c - XML : Get an array of string from text cut by element

perl - 为什么这个 xmlns 属性会打乱我的 xpath 查询?

iOS XML 解析器内存泄漏与 KissXML

libxml2 - libxml xmlNodeDump 编码问题

ios - 为什么NSDate的dateWithTimeIntervalSince1970修改其输入?

ios - 这一行代码在 Swift 2+ 中的等价物是什么