writeStartElement takes in a start element and writes it. It handles namespace, attributes in start element.
(w writer, el StartElement)
| 40 | // writeStartElement takes in a start element and writes it. |
| 41 | // It handles namespace, attributes in start element. |
| 42 | func 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". |
no test coverage detected