MCPcopy Create free account
hub / github.com/cogentcore/core / WriteStart

Method WriteStart

svg/xml.go:188–217  ·  view source on GitHub ↗
(start *xml.StartElement)

Source from the content-addressed store, hash-verified

186}
187
188func (xe *XMLEncoder) WriteStart(start *xml.StartElement) error {
189 if start.Name.Local == "" {
190 return fmt.Errorf("xml: start tag with no name")
191 }
192 if xe.CurStart != "" {
193 xe.WriteString(">")
194 xe.WriteEOL()
195 }
196 xe.WriteIndent()
197 xe.WriteString("<")
198 xe.WriteString(start.Name.Local)
199 xe.CurIndent++
200
201 xe.CurStart = start.Name.Local
202
203 // Attributes
204 for _, attr := range start.Attr {
205 name := attr.Name
206 if name.Local == "" {
207 continue
208 }
209 xe.WriteEOL()
210 xe.WriteIndent()
211 xe.WriteString(name.Local)
212 xe.WriteString(`="`)
213 xe.EscapeString(attr.Value, false)
214 xe.WriteString(`"`)
215 }
216 return nil
217}
218
219func (xe *XMLEncoder) WriteEnd(name string) error {
220 xe.CurIndent--

Callers 1

EncodeTokenMethod · 0.95

Calls 5

WriteStringMethod · 0.95
WriteEOLMethod · 0.95
WriteIndentMethod · 0.95
EscapeStringMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected