Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/mantyr/xmlutils

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mantyr/xmlutils

  • v1.0.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

XML utils

Build Status GoDoc Go Report Card Software License

This don't stable version

Implementation features

  • Ignore prefix in xml tag

    Now xml:"prefix:name" is interpreted by Unmarshal as xml:"name"

    This is necessary for the same behavior of Unmarshal/Marshal with prefix tags

  • Add support for xml.Unmarshaler

    Now there is no need to change all implementations of xml.Unmarshaler to xmlutils.Unmarshaler

  • Add forwarding xmlutils.Decoder to xml.Unmarshaler

    Now, regardless of how Unmarshal was launched (from xml or from xmlutils), you have the opportunity to use xmlutils where necessary

  • Move all existing structures from the fork back to encoding/xml

    Now this is implemented for most structures (such as xml.StartElement, xml.Name, xml.Attr, xml.Token and others), but I do not exclude that there is something else that can be transferred

Forwarding xmlutils.Decoder via the xml.UnmarshalXML interface

package main

import (
	"fmt"
	"encoding/xml"

	"github.com/mantyr/xmlutils"
)

type A struct {
	B struct {
		Data string `xml:"prefix:data"`
	}
}

func (a *A) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	return xmlutils.NewTokenDecoder(d, start).Decode(&a.B)
}

func main() {
	data := `<a><prefix:data>test</prefix:data></a>`
	a := &A{}
	err := xml.Unmarshal([]byte(data), &a)
	fmt.Println(err)
	fmt.Println(a.B.Data)
	// Output:
	// <nil>
	// test
}

Installation

$ go get -u github.com/mantyr/xmlutils

Author

Oleg Shevelev

FAQs

Package last updated on 15 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc