xmlutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanInvalid

func CleanInvalid(xmlStr string) string

CleanInvalid 去除XML文本中的无效字符。 CleanInvalid removes invalid characters from an XML string.

func CreateXPath

func CreateXPath(expr string) (*xpath.Expr, error)

CreateXPath 创建一个新的XPath对象。 CreateXPath creates a new XPath object.

func ElementText

func ElementText(doc *Document, tagName string) (string, error)

ElementText 根据节点名获得第一个子节点的文本值。 ElementText gets the text content of the first child element by tag name.

func GetByXPath

func GetByXPath(doc *Document, expr string) ([]*xmlquery.Node, error)

GetByXPath 通过XPath表达式获取XML节点。 GetByXPath gets XML nodes by an XPath expression.

func GetElement

func GetElement(doc *Document, tagName string) *xmlquery.Node

GetElement 根据节点名获得第一个子节点。 GetElement gets the first child element by tag name.

func GetElements

func GetElements(doc *Document, tagName string) []*xmlquery.Node

GetElements 根据节点名获得子节点列表。 GetElements gets a list of child elements by tag name.

func ReadObjectFromXML

func ReadObjectFromXML(filePath string, obj interface{}) error

ReadObjectFromXML 从XML中读取对象。 ReadObjectFromXML reads an object from an XML file.

func ToFile

func ToFile(doc *Document, filePath string) error

ToFile 将XML文档写入文件。 ToFile writes an XML document to a file.

func ToStr

func ToStr(doc *Document) (string, error)

ToStr 将XML文档转换为字符串。 ToStr converts an XML document to a string.

func TransElements

func TransElements(nodeList []*xmlquery.Node) []*xmlquery.Node

TransElements 将NodeList转换为Element列表。 TransElements converts a NodeList to a list of Elements.

func WriteObjectAsXML

func WriteObjectAsXML(obj interface{}, filePath string) error

WriteObjectAsXML 将可序列化的对象转换为XML写入文件。 WriteObjectAsXML writes a serializable object to an XML file.

Types

type Document

type Document struct {
	Root string
	*xmlquery.Node
}

Document 表示XML文档。 Document represents an XML document.

func CreateXML

func CreateXML(rootElementName string) *Document

CreateXML 创建一个新的XML文档。 CreateXML creates a new XML document.

func ParseXML

func ParseXML(xmlStr string) (*Document, error)

ParseXML 从字符串解析XML文档。 ParseXML parses an XML document from a string.

func ReadXML

func ReadXML(filePath string) (*Document, error)

ReadXML 从文件读取XML文档。 ReadXML reads an XML document from a file.

Jump to

Keyboard shortcuts

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