MCPcopy Create free account
hub / github.com/aws/smithy-go / GetElement

Method GetElement

encoding/xml/xml_decoder.go:82–101  ·  view source on GitHub ↗

GetElement looks for the given tag name at the current level, and returns the element if found, and skipping over non-matching elements. Returns an error if the node is not found, or if an error occurs while walking the document.

(name string)

Source from the content-addressed store, hash-verified

80// skipping over non-matching elements. Returns an error if the node is not found, or if an error occurs while walking
81// the document.
82func (d NodeDecoder) GetElement(name string) (t xml.StartElement, err error) {
83 for {
84 token, done, err := d.Token()
85 if err != nil {
86 return t, err
87 }
88 if done {
89 return t, fmt.Errorf("%s node not found", name)
90 }
91 switch {
92 case strings.EqualFold(name, token.Name.Local):
93 return token, nil
94 default:
95 err = d.Decoder.Skip()
96 if err != nil {
97 return t, err
98 }
99 }
100 }
101}
102
103// Value provides an abstraction to retrieve char data value within an xml element.
104// The method will return an error if it encounters a nested xml element instead of char data.

Callers

nothing calls this directly

Calls 2

TokenMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected