chenyunguiMilook / SwiftyXML

The most swifty way to deal with XML data in swift 5.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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: "&lt;")
}
}

Originally posted by @kiri11ko in #8 (comment)

commented

@kiri11ko, thanks for bringing this up, I will schedule to implement this recently.

commented

@kiri11ko I have fixed this issue