MCPcopy
hub / github.com/mmcdole/gofeed / ParseText

Function ParseText

internal/shared/parseutils.go:51–70  ·  view source on GitHub ↗

ParseText is a helper function for parsing the text from the current element of the XMLPullParser. This function can handle parsing naked XML text from an element.

(p *xpp.XMLPullParser)

Source from the content-addressed store, hash-verified

49// This function can handle parsing naked XML text from
50// an element.
51func ParseText(p *xpp.XMLPullParser) (string, error) {
52 var text struct {
53 Type string `xml:"type,attr"`
54 InnerXML string `xml:",innerxml"`
55 }
56
57 err := p.DecodeElement(&text)
58 if err != nil {
59 return "", err
60 }
61
62 result := text.InnerXML
63 result = strings.TrimSpace(result)
64
65 if strings.Contains(result, CDATA_START) {
66 return StripCDATA(result), nil
67 }
68
69 return DecodeEntities(result)
70}
71
72// StripCDATA removes CDATA tags from the string
73// content outside of CDATA tags is passed via DecodeEntities

Callers 10

parseChannelMethod · 0.92
parseItemMethod · 0.92
parseLinkMethod · 0.92
parseSourceMethod · 0.92
parseImageMethod · 0.92
parseGUIDMethod · 0.92
parseCategoryMethod · 0.92
parseTextInputMethod · 0.92
parseSkipHoursMethod · 0.92
parseSkipDaysMethod · 0.92

Calls 2

StripCDATAFunction · 0.85
DecodeEntitiesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…