Skip to content

Commit

Permalink
anyXML -> xmlElement
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryFissionGames committed Mar 14, 2024
1 parent 283db0e commit bde228e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/ottl/ottlfuncs/func_parse_xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func parseXML[K any](target ottl.StringGetter[K]) ottl.ExprFunc[K] {
return nil, err
}

parsedXML := anyXML{}
parsedXML := xmlElement{}

decoder := xml.NewDecoder(strings.NewReader(targetVal))
err = decoder.Decode(&parsedXML)
Expand All @@ -61,15 +61,15 @@ func parseXML[K any](target ottl.StringGetter[K]) ottl.ExprFunc[K] {
}
}

type anyXML struct {
type xmlElement struct {
tag string
attributes []xml.Attr
text string
children []anyXML
children []xmlElement
}

// UnmarshalXML implements xml.Unmarshaler for anyXML
func (a *anyXML) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
func (a *xmlElement) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
a.tag = start.Name.Local
a.attributes = start.Attr

Expand All @@ -81,7 +81,7 @@ func (a *anyXML) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {

switch t := tok.(type) {
case xml.StartElement:
child := anyXML{}
child := xmlElement{}
err := d.DecodeElement(&child, &t)
if err != nil {
return err
Expand All @@ -105,7 +105,7 @@ func (a *anyXML) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
}

// intoMap converts and adds the anyXML into the provided pcommon.Map.
func (a anyXML) intoMap(m pcommon.Map) {
func (a xmlElement) intoMap(m pcommon.Map) {
m.EnsureCapacity(4)

m.PutStr("tag", a.tag)
Expand Down

0 comments on commit bde228e

Please sign in to comment.