From 71c0046807bfd7e74c6ca3765463f5cbf6614051 Mon Sep 17 00:00:00 2001 From: Marcell Mars Date: Thu, 24 Mar 2022 11:25:03 +0100 Subject: [PATCH] few more hints for the future on how to use etree --- cmd/build.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/build.go b/cmd/build.go index 3239142..51cb114 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -61,12 +61,16 @@ should be enough for the next successful build).`, panic(err) } root := doc.SelectElement("rdf:RDF") - for _, z := range root.FindElements("[link:type]") { + for _, z := range root.FindElements("[name()='link:type']") { 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(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()) fmt.Println("+++++") fmt.Println(doc.WriteTo(os.Stdout))