ECoXiSSwift 生成 XML 內(nèi)容
ECoXiS 可以讓你在 Swift 語(yǔ)言中輕松創(chuàng)建 XML 內(nèi)容。
示例代碼:
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()評(píng)論
圖片
表情
