Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: decode error, such as <foo type="s" tp:type="string"> #19875

jouyouyun opened this Issue Apr 7, 2017 · 1 comment


None yet
3 participants
Copy link

jouyouyun commented Apr 7, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?


What operating system and processor architecture are you using (go env)?

linux 64

What did you do?

test code:

package main

import (

var xmlData = `
	<interface name="org.freedesktop.NetworkManager.Device.Gre">
		<signal name="Changed">
			<arg name="changed" type="s"></arg>

		<signal name="PropertiesChanged">
		    <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
		            A dictionary mapping property names to variant boxed values

type NodeInfo struct {
	Interface struct {
		Signals []SignalInfo `xml:"signal"`
	} `xml:"interface"`

type SignalInfo struct {
	Name string  `xml:"name,attr"`
	Arg  ArgInfo `xml:"arg"`

type ArgInfo struct {
	Name string `xml:"name,attr"`
	Type string `xml:"type,attr"`

func main() {
	reader := strings.NewReader(xmlData)
	decoder := xml.NewDecoder(reader)
	var info NodeInfo
	err := decoder.Decode(&info)
	if err != nil {
		fmt.Println("Failed to decode:", err)

	for _, signal := range info.Interface.Signals {
		fmt.Println("Signal:", signal.Name)
		fmt.Printf("\tName: %s\n\tType: %s\n", signal.Arg.Name, signal.Arg.Type)

I expected the signal PropertiesChanged 's type to a{sv}, but the result was String_Variant_Map.

What did you expect to see?

I expected the signal PropertiesChanged 's type to a{sv}

What did you see instead?

but the result was String_Variant_Map


This comment has been minimized.

Copy link

SamWhited commented Apr 25, 2017

Duplicate of section 4 on #14407 and, more specifically, of #8535; let's track this there. Thanks!

@SamWhited SamWhited closed this Apr 25, 2017

@golang golang locked and limited conversation to collaborators Apr 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.