setNamespaces(_:)
set this elements children nodes
func setNamespaces(_ namespaces: [XML.Node]?)
set this elements children nodes
func setNamespaces(_ namespaces: [XML.Node]?)
import SotoXML
final class Element
XML Element class
enum XML
Implemented to replace the XML Foundation classes. This was initially required as there is no implementation of the Foundation XMLNode classes in iOS. This is also here because the implementation of XMLNode in Linux Swift 4.2 was causing crashes. Whenever an XMLDocument was deleted all the underlying CoreFoundation objects were deleted. This meant if you still had a reference to a XMLElement from that document, while it was still valid the underlying CoreFoundation object had been deleted.
class Node
base class for all types of XML.Node
init(name: String, stringValue: String? = nil)
convenience init(xmlData: Data) throws
initialise XML.Element from xml data
init(xmlString: String) throws
initialise XML.Element from xml string
var attributes: [XML.Node]? { get }
array of attributes attached to XML ELement
var namespaces: [XML.Node]? { get }
array of namespaces attached to XML ELement
override var stringValue: String? { get set }
return child text nodes all concatenated together
override var xmlString: String { get }
return formatted XML
func addAttribute(_ node: XML.Node)
add an attribute to an element. If one with this name already exists it is replaced
func addChild(_ node: XML.Node)
add a child node to the xml element
func addNamespace(_ node: XML.Node)
add a namespace to an element. If one with this name already exists it is replaced
func attribute(forName: String) -> XML.Node?
return attribute attached to element
func elements(forName: String) -> [XML.Element]
return children XML elements
func insertChild(node: XML.Node, at index: Int)
insert a child node at position in the list of children nodes
func namespace(forName: String?) -> XML.Node?
return namespace attached to element
func setAttributes(_ attributes: [XML.Node]?)
set this elements children nodes
func setChildren(_ children: [XML.Node]?)
set this elements children nodes