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

Function writeStartElement

encoding/xml/value.go:42–61  ·  view source on GitHub ↗

writeStartElement takes in a start element and writes it. It handles namespace, attributes in start element.

(w writer, el StartElement)

Source from the content-addressed store, hash-verified

40// writeStartElement takes in a start element and writes it.
41// It handles namespace, attributes in start element.
42func writeStartElement(w writer, el StartElement) error {
43 if el.isZero() {
44 return fmt.Errorf("xml start element cannot be nil")
45 }
46
47 w.WriteRune(leftAngleBracket)
48
49 if len(el.Name.Space) != 0 {
50 escapeString(w, el.Name.Space)
51 w.WriteRune(colon)
52 }
53 escapeString(w, el.Name.Local)
54 for _, attr := range el.Attr {
55 w.WriteRune(' ')
56 writeAttribute(w, &attr)
57 }
58
59 w.WriteRune(rightAngleBracket)
60 return nil
61}
62
63// writeAttribute writes an attribute from a provided Attribute
64// For a namespace attribute, the attr.Name.Space must be defined as "xmlns".

Callers 1

newValueFunction · 0.85

Calls 5

escapeStringFunction · 0.85
writeAttributeFunction · 0.85
ErrorfMethod · 0.80
WriteRuneMethod · 0.65
isZeroMethod · 0.45

Tested by

no test coverage detected