package pkg import ( "errors" "strings" ) type XMLProfile struct { ProfileCommon MultipleQueryMatches string `json:"multiple_query_matches"` NamespaceMappings string `json:"namespace_mappings"` XPathQueries string `json:"xpath_queries"` } func ParseXMLProfile(raw string) (*XMLProfile, error) { p := new(XMLProfile) split := strings.Split(raw, "\n") if !strings.Contains(split[0], "ltm profile xml") { return nil, errors.New("not an xml profile") } p.ProfileCommon = parseCommon(raw) for _, line := range split { f := strings.Fields(line) switch strings.ToLower(f[0]) { case "multiple-query-matches": p.MultipleQueryMatches = strings.Join(f[1:], " ") case "namespace-mappings": p.NamespaceMappings = strings.Join(f[1:], " ") case "xpath-queries": p.XPathQueries = strings.Join(f[1:], " ") } } return p, nil }