xmlutils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 6 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.Element, specs *etree.Document) (*etree.Element, 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 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 PreviousSibling

func PreviousSibling(token etree.Token) etree.Token

PreviousSibling returns the previous sibling of the given token. If this is the first token of its parent, return this token.

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