Method: LibXML::XML::Parser#parse
- Defined in:
- ext/libxml/ruby_xml_parser.c
#parse ⇒ XML::Document
Parse the input XML and create an XML::Document with it’s content. If an error occurs, XML::Parser::ParseError is thrown.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'ext/libxml/ruby_xml_parser.c', line 63
static VALUE rxml_parser_parse(VALUE self)
{
xmlParserCtxtPtr ctxt;
VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
Data_Get_Struct(context, xmlParserCtxt, ctxt);
if ((xmlParseDocument(ctxt) == -1 || !ctxt->wellFormed) && ! ctxt->recovery)
{
if (ctxt->myDoc)
xmlFreeDoc(ctxt->myDoc);
rxml_raise(&ctxt->lastError);
}
rb_funcall(context, rb_intern("close"), 0);
return rxml_document_wrap(ctxt->myDoc);
}
|