문제 다음 charactersFoundSAX
및 errorEncounteredSAX
함수가 호출합니까libxml2를의 HTML 구문 분석 내가 HTML을 구문 분석 libxml2를 사용하고
static htmlSAXHandler simpleSAXHandlerStruct = {
NULL, /* internalSubset */
NULL, /* isStandalone */
NULL, /* hasInternalSubset */
NULL, /* hasExternalSubset */
NULL, /* resolveEntity */
NULL, /* getEntity */
NULL, /* entityDecl */
NULL, /* notationDecl */
NULL, /* attributeDecl */
NULL, /* elementDecl */
NULL, /* unparsedEntityDecl */
NULL, /* setDocumentLocator */
NULL, /* startDocument */
NULL, /* endDocument */
NULL, /* startElement*/
NULL, /* endElement */
NULL, /* reference */
charactersFoundSAX, /* characters */
NULL, /* ignorableWhitespace */
NULL, /* processingInstruction */
NULL, /* comment */
NULL, /* warning */
errorEncounteredSAX, /* error */
NULL, /* fatalError //: unused error() get all the errors */
NULL, /* getParameterEntity */
NULL, /* cdataBlock */
NULL, /* externalSubset */
XML_SAX2_MAGIC, //
NULL,
startElementSAXP, /* startElementNs */
endElementSAXP, /* endElementNs */
NULL, /* serror */
};
하지만 startElementSAXP
및 endElementSAXP
기능을 결코 호출 얻을.
구문 분석을 변경하고 XML을 구문 분석 한 다음 (예 : xmlSAXHandler
) 'html'을 포함한 모든 정의를 'xml'로 변경하면 함수가 올바르게 호출됩니다.
왜 그럴까요?
당신은 무엇을 의미합니까 : 나는 HTML의 구문 분석을 변경하고 대신 XML을 구문 분석하는 경우? 우리가 실제로 HTML/XML 파일을 파기 시작할 수 있도록주의를 기울여야할까요? 제가 말할 수있는 것은 HTML SAX 파서가 작동한다는 것입니다. – hroptatyr
'http : // www.google.com/index.html'을 사용해보세요. 이 두 함수가 파서에서 호출되는지 확인하십시오. http://xmlsoft.org/html/libxml-parser.html#startElementNsSAX2Func http://xmlsoft.org/html/libxml-parser.html#endElementNsSAX2Func – ryyst
아니, 나는 html 모드에서 NS 인식 기능 슬롯을 사용하지 않습니다. 그게 네 문제 겠지, HTML은 네임 스페이스에 대한 개념이 없다. 어쩌면 startElement/endElement 슬롯을 사용하는 편이 낫겠 니? – hroptatyr