You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by rohitajm <ro...@rediffmail.com> on 2006/11/17 11:16:33 UTC

How to use Xerces

Hi,

I am new to Xerces world. I am to generate an Xml file from Visual Studio
2003. I have Windows Xp. 

What steps I should take to create this. Is there any good tutorial for
this, please forward. 

I am using following code in _tmain(...), but getting error: "SAX2XMLREADER:
undeclared identifier"

	char* xmlFile = "x1.xml";
	SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
	parser->setFeature(XMLUni::fgSAX2CoreValidation, true); // optional
	parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); // optional
	DefaultHandler* defaultHandler = new DefaultHandler();
	parser->setContentHandler(defaultHandler);
	parser->setErrorHandler(defaultHandler);

	try {
		parser->parse(xmlFile);
	}
	catch (const XMLException& toCatch) {
                ...
                }

Please help.

-- 
View this message in context: http://www.nabble.com/How-to-use-Xerces-tf2650611.html#a7396875
Sent from the Xerces - C - Users mailing list archive at Nabble.com.


Re: How to use Xerces

Posted by Alberto Massari <am...@datadirect.com>.
At 02.16 17/11/2006 -0800, rohitajm wrote:

>Hi,
>
>I am new to Xerces world. I am to generate an Xml file from Visual Studio
>2003. I have Windows Xp.

Uhm, why do you use the SAX parser (that reads an XML file) if you 
plan to generate one?


>What steps I should take to create this. Is there any good tutorial for
>this, please forward.

If you really want to read an XML file using the SAX2XMLParser, look 
at the SAX2Print example.

>I am using following code in _tmain(...), but getting error: "SAX2XMLREADER:
>undeclared identifier"

You are missing a #include <xercesc/sax2/SAX2XMLReader.hpp> statement

Alberto


>         char* xmlFile = "x1.xml";
>         SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
>         parser->setFeature(XMLUni::fgSAX2CoreValidation, true); // optional
>         parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); // optional
>         DefaultHandler* defaultHandler = new DefaultHandler();
>         parser->setContentHandler(defaultHandler);
>         parser->setErrorHandler(defaultHandler);
>
>         try {
>                 parser->parse(xmlFile);
>         }
>         catch (const XMLException& toCatch) {
>                 ...
>                 }
>
>Please help.
>
>--
>View this message in context: 
>http://www.nabble.com/How-to-use-Xerces-tf2650611.html#a7396875
>Sent from the Xerces - C - Users mailing list archive at Nabble.com.