gxml

package
v2.10.6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 Imported by: 12 modules, 17 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gxml provides accessing and converting for XML content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(content []byte) (map[string]any, error)

Decode parses `content` into and returns as map.

func DecodeWithoutRoot

func DecodeWithoutRoot(content []byte) (map[string]any, error)

DecodeWithoutRoot parses `content` into a map, and returns the map without root level.

func Encode

func Encode(m map[string]any, rootTag ...string) ([]byte, error)

Encode encodes map `m` to an XML format content as bytes. The optional parameter `rootTag` is used to specify the XML root tag.

func EncodeWithIndent

func EncodeWithIndent(m map[string]any, rootTag ...string) ([]byte, error)

EncodeWithIndent encodes map `m` to an XML format content as bytes with indent. The optional parameter `rootTag` is used to specify the XML root tag.

func ToJson

func ToJson(content []byte) ([]byte, error)

ToJson converts `content` as XML format into JSON format bytes.

func XMLEscapeChars added in v2.7.4

func XMLEscapeChars(b ...bool)

XMLEscapeChars forces escaping invalid characters in attribute and element values. NOTE: this is brute force with NO interrogation of '&' being escaped already; if it is then '&' will be re-escaped as '&'.

The values are:
"   "
'   '
<   &lt;
>   &gt;
&   &amp;

Note: if XMLEscapeCharsDecoder(true) has been called - or the default, 'false,' value has been toggled to 'true' - then XMLEscapeChars(true) is ignored. If XMLEscapeChars(true) has already been called before XMLEscapeCharsDecoder(true), XMLEscapeChars(false) is called to turn escape encoding on mv.Xml, etc., to prevent double escaping ampersands, '&'.

Types

This section is empty.

Jump to

Keyboard shortcuts

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