Documentation
¶
Overview ¶
Package xml provides APOC XML processing functions.
This package implements all apoc.xml.* functions for parsing, manipulating, and generating XML data.
Index ¶
- func Escape(text string) string
- func FromJson(jsonStr string) (string, error)
- func GetAttribute(elem *Element, name string) string
- func GetNamespace(elem *Element, prefix string) string
- func GetText(elem *Element) string
- func Minify(xmlStr string) string
- func Prettify(xmlStr string) (string, error)
- func ToJson(xmlStr string) (string, error)
- func ToMap(elem *Element) map[string]interface{}
- func ToString(elem *Element) string
- func Transform(xmlStr, xsltStr string) (string, error)
- func Unescape(text string) string
- func Validate(xmlStr, schemaStr string) map[string]interface{}
- type Element
- func AddChild(parent, child *Element) *Element
- func Clone(elem *Element) *Element
- func Create(name string, attributes map[string]string, text string) *Element
- func FromMap(data map[string]interface{}) *Element
- func Namespace(elem *Element, prefix, uri string) *Element
- func Parse(xmlStr string) (*Element, error)
- func Query(elem *Element, path string) []*Element
- func RemoveChild(parent, child *Element) *Element
- func SetAttribute(elem *Element, name, value string) *Element
- func SetText(elem *Element, text string) *Element
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Escape ¶
Escape escapes special XML characters.
Example:
apoc.xml.escape('<tag>') => '<tag>'
func GetAttribute ¶
GetAttribute gets attribute value.
Example:
apoc.xml.getAttribute(element, 'id') => 'value'
func GetNamespace ¶
GetNamespace gets namespace URI.
Example:
apoc.xml.getNamespace(element, 'ns') => 'http://example.com'
func Prettify ¶
Prettify formats XML with indentation.
Example:
apoc.xml.prettify(xmlStr) => formatted XML
func ToMap ¶
ToMap converts XML to map structure.
Example:
apoc.xml.toMap(element) => {name: 'root', children: [...]}
func ToString ¶
ToString converts structure to XML string.
Example:
apoc.xml.toString(element) => '<root><item>value</item></root>'
func Transform ¶
Transform transforms XML using XSLT.
Example:
apoc.xml.transform(xmlStr, xsltStr) => transformed XML
Types ¶
type Element ¶
Element represents an XML element.
func Create ¶
Create creates a new element.
Example:
apoc.xml.create('item', {id: '1'}, 'text') => element
func FromMap ¶
FromMap creates XML from map structure.
Example:
apoc.xml.fromMap({name: 'root', text: 'value'}) => element
func Namespace ¶
Namespace handles XML namespaces.
Example:
apoc.xml.namespace(element, 'ns', 'http://example.com') => element
func Parse ¶
Parse parses XML string to structure.
Example:
apoc.xml.parse('<root><item>value</item></root>') => parsed structure
func Query ¶
Query queries XML using XPath-like syntax.
Example:
apoc.xml.query(element, '//item[@id="1"]') => matching elements
func RemoveChild ¶
RemoveChild removes a child element.
Example:
apoc.xml.removeChild(parent, child) => parent
func SetAttribute ¶
SetAttribute sets attribute value.
Example:
apoc.xml.setAttribute(element, 'id', 'value') => element