-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_XML.go
42 lines (31 loc) · 1 KB
/
mod_XML.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"log"
"github.com/beevik/etree"
)
func CreatePlist(ipa Ipa) bool {
doc := GetXMLDoc("template.plist")
el := doc.FindElement("//array[1]/dict[1]/string[2]")
el.SetText(ipa.URL)
el = doc.FindElement("//dict[2]/string[2]")
el.SetText(cfg.Service.Url + "/ipa/" + ipa.SHA256 + "/display-image.png")
el = doc.FindElement("//dict[3]/string[2]")
el.SetText(cfg.Service.Url + "/ipa/" + ipa.SHA256 + "/full-size-image.png")
el = doc.FindElement("//dict[1]/dict[1]/string[1]")
el.SetText(ipa.CFBundleIdentifier)
el = doc.FindElement("//dict[1]/dict[1]/string[2]")
el.SetText(ipa.CFBundleVersion)
el = doc.FindElement("//string[4]")
el.SetText(ipa.CFBundleName)
doc.WriteToFile(fmt.Sprintf(".\\ipa\\%s\\%s.plist", ipa.SHA256, ipa.CFBundleName))
return true
}
func GetXMLDoc(configPath string) *etree.Document {
doc := etree.NewDocument()
if err := doc.ReadFromFile(configPath); err != nil {
log.Println("Error parse "+configPath+": ", err.Error())
return nil
}
return doc
}