ECoXiSSwift 生成 XML 内容
ECoXiS 可以让你在 Swift 语言中轻松创建 XML 内容。
示例代码:
func template(title: String, message: String) -> XMLDocument { let titleTextNode = <&title return XML( <"html" | ["lang": "en", "xmlns": "http://www.w3.org/1999/xhtml"] | [ <"head" | [<"title" | titleTextNode], <"body" | [ <"h1" | titleTextNode, <"p!" | <&message, <!"This is a comment, multiple --- are collapsed!--", PI("processing-instruction-target", "PI?> content") ] ], omitXMLDeclaration: true, doctype: Doctype() ) } //使用方法 template("<Foo Bar>", "Hello world!").toString()
评论