本文整理匯總了Golang中github.com/beevik/etree.Document.ReadFromBytes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Document.ReadFromBytes方法的具體用法?Golang Document.ReadFromBytes怎麽用?Golang Document.ReadFromBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/beevik/etree.Document
的用法示例。
在下文中一共展示了Document.ReadFromBytes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doFile
//.........這裏部分代碼省略.........
hasMeta = true
fixedDone = true
}
case "meta":
meta = ""
for _, e := range t.Attr {
if e.Name.Local == "id" {
meta = e.Value
break
}
}
state.inMeta = native_use[meta]
case "foreign-data":
if !state.inMetadata {
x(fmt.Errorf("Invalid tag <foreign-data>"))
}
x(d.Skip())
offset2 := d.InputOffset()
fp, err := os.Open(currentfile)
x(err)
_, err = fp.Seek(offset1, 0)
if err != nil {
fp.Close()
x(err)
}
data2 := make([]byte, offset2-offset1)
_, err = io.ReadFull(fp, data2)
fp.Close()
x(err)
doc2 = etree.NewDocument()
data := []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
data = append(data, data2...)
x(doc2.ReadFromBytes(data))
x(err)
for _, item := range fixed2 {
found := false
for _, t := range doc2.FindElements(cfg.Items[item].XPath2) {
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)
}
}
hasMeta2 = true
fixedDone2 = true
case "s":
teller++
if !state.inSkip {
if state.inS {
if !cfg.Tokenized {
state.inSkip = true
}
} else {
if id == "" {
label = fmt.Sprintf("%s.s.%d", filename, teller)