For make true XML need in the loop get all value and fix then.
kiri11ko opened this issue · comments
For make true XML need in the loop get all value and fix then.
Example:
let newXMLHead: XML = XML(name: "clients")
let usersXML: [XML] = memoryXML!["#clients"]["client"].xmlList!
for value in usersXML {
let newXML: XML = XML(name: "clients")
for (key, subValue) in value.attributes {
newXML.addAttribute(name: key, value: subValue.percentEscapeString())
}
newXMLHead.addChild(newXML)
}
Where
extension String {
func percentEscapeString() -> String {
return self
.replacingOccurrences(of: "&", with: "&")
.replacingOccurrences(of: """, with: """)
.replacingOccurrences(of: "'", with: "'")
.replacingOccurrences(of: ">", with: ">")
.replacingOccurrences(of: "<", with: "<")
}
}
Originally posted by @kiri11ko in #8 (comment)