本文整理匯總了Golang中github.com/beevik/etree.Document.ReadFromFile方法的典型用法代碼示例。如果您正苦於以下問題:Golang Document.ReadFromFile方法的具體用法?Golang Document.ReadFromFile怎麽用?Golang Document.ReadFromFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/beevik/etree.Document
的用法示例。
在下文中一共展示了Document.ReadFromFile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doFile
//.........這裏部分代碼省略.........
case "id":
id = e.Value
case "class":
hasClass = true
case "auth":
state.inSkip = true
}
}
switch t.Name.Local {
case "metadata":
state.inMetadata = true
var src string
for _, e := range t.Attr {
if e.Name.Local == "src" {
src = e.Value
break
}
}
if src != "" {
if cfg.Meta_src != "" {
fmt.Fprintf(fpout, "##META text %s = %s\n", cfg.Meta_src, src)
}
srcs := make([]string, 0, 4)
if dirname != "" {
srcs = append(srcs, filepath.Join(dirname, src+".xml"), filepath.Join(dirname, src))
}
srcs = append(srcs, src+".xml", src)
for i, src := range srcs {
doc = etree.NewDocument()
err := doc.ReadFromFile(filepath.Join(cfg.Meta_dir, src))
if err == nil {
break
}
if i == len(srcs)-1 {
x(err)
}
}
for _, item := range fixed {
found := false
for _, t := range doc.FindElements(cfg.Items[item].XPath) {
value := t.Text()
if cfg.Items[item].hasFilter {
val, err := vm.Run(fmt.Sprintf("fn[%q](%q);", item, value))
x(err, "\nRunning function for "+item+":\n"+cfg.Items[item].Filter)
value = val.String()
}
if value != "" && oktype(item, value) {
found = true
fmt.Fprintf(fpout, "##META %s %s = %s\n", cfg.Items[item].Type, item, value)
}
}
if !found {
fmt.Fprintf(os.Stderr, "Niet gevonden in %s voor (%s) %s\n", currentfile, cfg.Items[item].Type, item)
fmt.Fprintf(fpout, "##META %s %s =\n", cfg.Items[item].Type, item)
}
}
hasMeta = true
fixedDone = true
}
case "meta":
meta = ""