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)
| 49 | // This function can handle parsing naked XML text from |
| 50 | // an element. |
| 51 | func 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 |
no test coverage detected
searching dependent graphs…