few more hints for the future on how to use etree

This commit is contained in:
Marcell Mars 2022-03-24 11:25:03 +01:00
parent b668476c47
commit 71c0046807
1 changed files with 7 additions and 3 deletions

View File

@ -61,12 +61,16 @@ should be enough for the next successful build).`,
panic(err) panic(err)
} }
root := doc.SelectElement("rdf:RDF") root := doc.SelectElement("rdf:RDF")
for _, z := range root.FindElements("[link:type]") { for _, z := range root.FindElements("[name()='link:type']") {
doc := etree.NewDocument() doc := etree.NewDocument()
doc.SetRoot(z.Copy()) doc.SetRoot(z.Parent().Copy())
if z.Text() != "application/pdf" {
continue
}
fmt.Println(z.Text())
fmt.Println("~ ~ ~ ~") fmt.Println("~ ~ ~ ~")
fmt.Println(doc.WriteTo(os.Stdout)) fmt.Println(doc.WriteTo(os.Stdout))
elm := root.FindElement(fmt.Sprintf("[@rdf:resource='%s']", z.SelectAttr("rdf:about").Value)) elm := root.FindElement(fmt.Sprintf("[@rdf:resource='%s']", z.Parent().SelectAttr("rdf:about").Value))
doc.SetRoot(elm.Parent().Copy()) doc.SetRoot(elm.Parent().Copy())
fmt.Println("+++++") fmt.Println("+++++")
fmt.Println(doc.WriteTo(os.Stdout)) fmt.Println(doc.WriteTo(os.Stdout))