Recent Changes - Search:

Accueil

OpenSSL

SyncML

Apache Portable Runtime

Libxml2

Net-snmp

CUrl

Boost

Perl

ZLib

Samba

VPN

Serveurs de messagerie

edit

Libxml2/Libxml2-html-parsing

Libxml2.Libxml2-html-parsing History

Hide minor edits - Show changes to markup

May 12, 2007, at 06:01 AM by Arnaud Grandville -
Changed lines 1-3 from:

Dans le répertoire \libxml2-2.6.23\win32\bin.msvc se trouvent un exécutable permettant le parsing d'un fichier HTML.

to:

Dans le répertoire \libxml2-2.6.23\win32\bin.msvc se trouve un exécutable permettant le parsing d'un fichier HTML.

Changed lines 9-11 from:

Voici le code source d'un programme faisant l'analyse syntaxique de pages HTML

to:

Voici le code source d'un autre programme faisant aussi l'analyse syntaxique de pages HTML

Deleted line 21:
Deleted lines 23-24:
Deleted lines 79-80:
Deleted lines 83-84:
Deleted line 111:
March 03, 2006, at 11:21 AM by 194.2.239.195 -
Changed lines 6-8 from:

Le parsing d'une page contenant des erreurs grâves peut se faire en créant des fonctions SAX error callbacks vides.

to:

Le parsing d'une page contenant des erreurs grâves peut se faire en ne créant pas des fonctions SAX error callbacks correspondantes.

March 02, 2006, at 01:39 PM by 194.2.239.195 -
Changed lines 9-120 from:
to:

Voici le code source d'un programme faisant l'analyse syntaxique de pages HTML

(:source lang=C :)

  1. include <stdio.h>
  2. include <libxml/HTMLparser.h>

int iDepth=0;

static void endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) {

    iDepth--;

}

static void startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) {

    iDepth++;
	fprintf(stdout,"%2i.",iDepth);
	for (int i = 0; i < iDepth; i++)
		fprintf(stdout,"  ");

    fprintf(stdout, "<%s", (char *) name);

	if (atts != NULL) {
        for (i = 0;(atts[i] != NULL);i++) {
			fprintf(stdout, ", %s='", atts[i++]);
			if (atts[i] != NULL)
				fprintf(stdout, "%s'", atts[i]);
		}
    }
	fprintf(stdout, ">\n");

}

static xmlSAXHandler debugSAXHandlerStruct = {

    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 */
		startElementDebug, /* startElement */
		endElementDebug, /* endElement */
		NULL, /* reference */
		NULL, /* characters */
		NULL, /* ignorableWhitespace */
		NULL, /* processingInstruction */
		NULL, /* comment */
		NULL, /* xmlParserWarning */
		NULL, /* xmlParserError */
		NULL, /* xmlParserError */
		NULL, /* getParameterEntity */
		NULL, /* cdataBlock */
		NULL, /* externalSubset */
		1,    /* initialized */
		NULL, /* private */
		NULL, /* startElementNsSAX2Func */
		NULL, /* endElementNsSAX2Func */
		NULL  /* xmlStructuredErrorFunc */

};

xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;

int main(int argc, char* argv[]) {

	FILE *f;

	f = fopen(argv[1], "r");
	if (f != NULL) {
		int res, size = 1024;
		char chars[1024];
		htmlParserCtxtPtr ctxt;

		res = fread(chars, 1, 4, f);
		if (res > 0) {

			ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL,chars, 4,argv[1],XML_CHAR_ENCODING_UTF8);

			while ((res = fread(chars, 1, size, f)) > 0) {
				htmlParseChunk(ctxt, chars, res, 0);
			}
			xmlParseChunk(ctxt, chars, 0, 1);
			xmlFreeParserCtxt(ctxt);
		}
	}

	return 0;

}

(:sourcend:)

March 02, 2006, at 10:22 AM by 194.2.239.195 -
Added lines 1-9:

Dans le répertoire \libxml2-2.6.23\win32\bin.msvc se trouvent un exécutable permettant le parsing d'un fichier HTML.

xmllint.exe --html C:\step1.html

Le parsing d'une page contenant des erreurs grâves peut se faire en créant des fonctions SAX error callbacks vides.

Edit - History - Print - Recent Changes - Search
Page last modified on May 12, 2007, at 06:01 AM