package util import ( "strings" ) func ParseXmlNode(data string) (string, string, string) { a, b := findString(data, "<", ">") if a == -1 { return "", "", data } return ParseXmlNameNode(data, data[a:b]) } func findString(data string, start string, end string) (int, int) { index1 := strings.Index(data, start) if index1 < 0 { return -1, -1 } index2 := strings.Index(data, end) if index2 < 0 { return -1, -1 } return index1 + len(start), index2 } func ParseXmlNameNode(data string, name string) (string, string, string) { start := "<" + name + ">" end := "" a, b := findString(data, start, end) if a == -1 { return "", "", data } a -= len(start) b += len(end) return name, data[a:b], data[b:] } func ParseXmlNameData(data string, name []string) string { var n string for i := 0; i < len(name); i++ { n, data, _ = ParseXmlNameNode(data, name[i]) if n == "" { return "" } } a, b := findString(data, "<" + n + ">", "") return data[a:b] }