XMLContent
public struct XMLContent
A navigable cursor over the parsed XML content of a VAST extension payload.
Returned by xmlContent and xmlContent.
Use name to identify the root element, subscript navigation to reach named child elements,
then read text or attribute(_:).
// xmlString = "<CustomData><Title>My Ad</Title><Tag event="start">url</Tag></CustomData>"
let root = extension.xmlContent.name // "CustomData"
let title = extension.xmlContent["Title"].text
let event = extension.xmlContent["Tag"].attribute("event")
let tags = extension.xmlContent["Tag"].all.compactMap { $0.text }
-
Returns a cursor over direct children of the current element whose name equals
key. Returns an empty cursor when no matching children exist.Declaration
Swift
public subscript(key: String) -> XMLContent { get } -
The XML element name of this node, or
nilif the cursor is empty.Declaration
Swift
public var name: String? { get } -
The raw text content of this element, or
nilif the element is absent.Declaration
Swift
public var text: String? { get } -
Expands repeated sibling elements at this level into individual cursors for iteration.
Declaration
Swift
public var all: [XMLContent] { get } -
Returns the string value of attribute
name, ornilif the attribute is absent.Declaration
Swift
public func attribute(_ name: String) -> String? -
Returns the serialized XML of this element, or
nilif the element is absent.Declaration
Swift
public func toString() -> String?