xmlutils

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package xmlutils provides utilities for working with XML in the context of the Hexya Framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyExtensions

func ApplyExtensions(base *etree.Document, specs *etree.Document) (*etree.Document, error)

ApplyExtensions returns a copy of base with extension specs applied.

func ConcatXML

func ConcatXML(fileNames []string) ([]byte, [sha1.Size]byte, error)

ConcatXML concatenates the XML content of the files given by fileNames into a valid XML by importing all children of the root node into the root node of the first file. This function also returns the sha1sum of the result.

func CopyElement

func CopyElement(element *etree.Element) *etree.Element

CopyElement deep copies the given element, setting it as root to a new document

func DocumentToXML added in v0.1.7

func DocumentToXML(doc *etree.Document) ([]byte, error)

DocumentToXML returns the XML bytes of the given document

func DocumentToXMLNoIndent added in v0.1.7

func DocumentToXMLNoIndent(doc *etree.Document) ([]byte, error)

DocumentToXMLNoIndent returns the XML bytes of the given document without indenting the result.

Use this function when the XML is HTML that needs to keep <tag></tag> syntax

func ElementToXML

func ElementToXML(element *etree.Element) ([]byte, error)

ElementToXML returns the XML bytes of the given element and all its children.

func ElementToXMLNoIndent

func ElementToXMLNoIndent(element *etree.Element) ([]byte, error)

ElementToXMLNoIndent returns the XML bytes of the given element and all its children, without indenting the result.

Use this function when the XML is HTML that needs to keep <tag></tag> syntax

func HasParentTag

func HasParentTag(element *etree.Element, parent string) bool

HasParentTag returns true if this element has at least one ancestor node with the given parent tag name

func NextSibling

func NextSibling(token etree.Token) etree.Token

NextSibling returns the next sibling of the given token or nil if this is the last token of its parent

func XMLToDocument

func XMLToDocument(xmlStr string) (*etree.Document, error)

XMLToDocument parses the given xml string and returns an etree.Document

func XMLToElement

func XMLToElement(xmlStr string) (*etree.Element, error)

XMLToElement parses the given xml string and returns the root node

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL