xpath - GoLang - XmlPath Selectors with HTML -


i looking @ documented example here, iterating purely on xml tree, , not html. therefore, still partly confused.

for example, if wanted find specific meta tag within head tag name, seems cannot? instead, need find order in head tag. in case, want 8th meta tag, assume is:

headtag, err := getbyid(xmlroot, "/head/meta[8]/")

but of course, using getbyid function tag name - don't believe work. what full list of "getby..." commands?

then, problem is, how access meta tag's contents? documentation provides examples inner tag node content. however, example work?:

resp.query = extractvalue(headtag, @content)

the @ selector confuses me, appropriate case?

in other words:

  1. is there proper html example available?
  2. is there list of correct selectors ids, tags, etc?
  3. can tags found name, , content extracted inner content tag?

thank much!

xpath not seem suitable here; should using goquery, designed html.

here example:

package main  import (     "fmt"      "github.com/puerkitobio/goquery" )  func main() {     doc, err := goquery.newdocument("https://example.com")     if err != nil {         panic(err)     }     s := doc.find(`html > head > meta[name="viewport"]`)     if s.length() == 0 {         fmt.println("could not find viewpoint")         return     }     fmt.println(s.eq(0).attror("content", "")) } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -