www.destructor.de
If the package that comes with the XML parser does not work in your version of C++Builder, try this:
By Rajeev Rajan (Qualcomm Inc, USA)
By Victor Olaru
In BCB6 select "Components ยป Install Component". Select the "Into new package" tab. In the Unit file name manually write the path to LibXmlComps.pas and xmlparser.cpp files, because by clicking browse you can select only one file type (either cpp or pas). Please note that the paths should be written like in the following example: "C:\XML\xmlparser.cpp" "C:\XML\LibXmlParser.pas". You should type a name in the Package file name and then click ok. Let the IDE compile and install and there you have it!
Now, I am not really shure if I included or not the other .pas file, but my guess is that I didn't... oh well, hope you would get the idea.
By Fabrizio Benedetti
The main issue was in having the component usable from C++: there is some option to tell the Delphi linker to generate C++ files, and failing to specify that makes the component only available from Delphi forms. Those options are, in Delphi projects, under "linker" category, and in C++ project, under "Delphi compiler | other options". The only thing left to do is to manually add the package path to the client projects' include paths list, because .hpp files are output to that location - I think this could be fixed with some more work.
By Rajeev Rajan (Qualcomm Inc, USA)
//-- Load the input xml file, and call execute. xmlScanner->LoadFromFile("c:\\myfile.xml"); xmlScanner->Execute();
That's it, as your file is parsed, your various event call-back functions will be automatically called.
If you want to use the TXmlParser component from within TXmlScanner, a pointer to the same is available in the TXmlScanner object. I've given some sample code below on how to use it.
For example:
If XmlScanner1 is the name of your TXmlScanner object:
//-- Load the input xml file.. XmlScanner1->LoadFromFile("c:\\myfile.xml"); //-- Init the scanning. XmlScanner1->XmlParser->StartScan(); //-- Loop thru the file for each item. AnsiString s; while (XmlScanner1->XmlParser->Scan()) { switch (XmlScanner1->XmlParser->CurPartType) { case ptStartTag : //-- Got Start tag. s = XmlScanner1->XmlParser->CurName; break; case ptContent : //-- Got content. s = XmlScanner1->XmlParser->CurContent; break; //-- Add other cases here as required.. default : break; } }
2000-07-27 Rajeev Rajan
2001-02-28 Stefan Heymann: Added a note on the OnLoadExternal problem
2001-08-24 Stefan Heymann: Removed the "compilation problems" section. AFAIK there are
none any more.
2006-01-10 Added BCB6 instructions. Thanks to Victor Olaru
2010-01-01 Added BCB2007 instructions. Thanks to Fabrizio Benedetti
2010-02-04 Added General instructions