Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bserdar/go-dom
XML DOM implementation for Go
https://github.com/bserdar/go-dom
dom dom-manipulation go xml
Last synced: about 1 month ago
JSON representation
XML DOM implementation for Go
- Host: GitHub
- URL: https://github.com/bserdar/go-dom
- Owner: bserdar
- License: apache-2.0
- Created: 2022-01-16T23:48:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-30T04:13:23.000Z (about 1 year ago)
- Last Synced: 2023-11-01T02:42:38.725Z (about 1 year ago)
- Topics: dom, dom-manipulation, go, xml
- Language: Go
- Homepage:
- Size: 161 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/bserdar/go-dom?status.svg)](https://godoc.org/github.com/bserdar/go-dom)
[![Go Report Card](https://goreportcard.com/badge/github.com/bserdar/go-dom)](https://goreportcard.com/report/github.com/bserdar/go-dom)
[![Build Status](https://github.com/bserdar/go-dom/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/bserdar/go-dom/actions/workflows/CI.yml)
# XML DOM Implementation for GoThis is a library to programmatically create, read, and modify XML
documents using Go without marshaling/unmarshaling them into
structures. It somewhat follows the XML DOM specification with the
following exceptions:* This implementation preserves and exposes XML namespace prefixes
* Elements can be created with namespaces and prefixes
* CDATA sections are converted to text nodes
## Namespace NormalizationThe `Document` interface has a `NormalizeNamespaces()` method that
should be called before serializing the document. It does the following:* If there are elements/attributes with namespaces with no associated
prefixes, then it create prefixes for them
* If there are elements/attributes with prefixes that are not
defined, it returns error
## SerializationTo parse XML documents, use the `Parse` function with an
`xml.Decoder.` By changing the `Strict` and `Entities` fields of a
`Decoder`, this parser can be used to parse HTML data.To encode a `Document` as XML, first call `NormalizeNamespaces()`
function, and then use the `Encode` function.