Source File
element.go
Belonging Package
github.com/aws/smithy-go/encoding/xml
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Copied and modified from Go 1.14 stdlib's encoding/xml
package xml
// A Name represents an XML name (Local) annotated
// with a name space identifier (Space).
// In tokens returned by Decoder.Token, the Space identifier
// is given as a canonical URL, not the short prefix used
// in the document being parsed.
type Name struct {
Space, Local string
}
// An Attr represents an attribute in an XML element (Name=Value).
type Attr struct {
Name Name
Value string
}
/*
NewAttribute returns a pointer to an attribute.
It takes in a local name aka attribute name, and value
representing the attribute value.
*/
func (, string) Attr {
return Attr{
Name: Name{
Local: ,
},
Value: ,
}
}
/*
NewNamespaceAttribute returns a pointer to an attribute.
It takes in a local name aka attribute name, and value
representing the attribute value.
NewNamespaceAttribute appends `xmlns:` in front of namespace
prefix.
For creating a name space attribute representing
`xmlns:prefix="http://example.com`, the breakdown would be:
local = "prefix"
value = "http://example.com"
*/
func (, string) Attr {
:= NewAttribute(, )
// default name space identifier
.Name.Space = "xmlns"
return
}
// A StartElement represents an XML start element.
type StartElement struct {
Name Name
Attr []Attr
}
// Copy creates a new copy of StartElement.
func ( StartElement) () StartElement {
:= make([]Attr, len(.Attr))
copy(, .Attr)
.Attr =
return
}
// End returns the corresponding XML end element.
func ( StartElement) () EndElement {
return EndElement{.Name}
}
// returns true if start element local name is empty
func ( StartElement) () bool {
return len(.Name.Local) == 0
}
// An EndElement represents an XML end element.
type EndElement struct {
Name Name
}
// returns true if end element local name is empty
func ( EndElement) () bool {
return len(.Name.Local) == 0
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)