// Parse html object with doc - used in testing for "forwarding" samlresponses from html to http // Disables error reporting - libxml2 complains about html5 elements func NewHtmlXp(html []byte) *Xp { x := new(Xp) //x.doc = C.htmlParseDoc((*C.xmlChar)(unsafe.Pointer(&html[0])), nil) ctxt := C.htmlCreateMemoryParserCtxt((*C.char)(unsafe.Pointer(&html[0])), C.int(len(html))) C.htmlCtxtUseOptions(ctxt, C.HTML_PARSE_NOERROR) C.htmlParseDocument(ctxt) x.doc = ctxt.myDoc C.htmlFreeParserCtxt(ctxt) x.xpathCtx = C.xmlXPathNewContext(x.doc) runtime.SetFinalizer(x, (*Xp).free) return x }
// htmlFreeParserCtxt func (p *HTMLParser) Free() { C.htmlFreeParserCtxt(p.Ptr) }