本文整理汇总了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)