Powerbasic Museum 2020-B

Webmaster: José Roca (PBWIN 10+/PBCC 6+) (SDK Forum) => COM Programming => Topic started by: Bernard Ertl on February 04, 2015, 03:31:32 PM

Title: XML
Post by: Bernard Ertl on February 04, 2015, 03:31:32 PM
I'm new to XML and needing to build a routine that imports some data from an XML file. 

I saw Jose's thread on MSXML here:

http://www.jose.it-berater.org/smfforum/index.php?topic=4387.0

I also saw his old post in the PB forums which mentioned a freeware library TB_XML40.zip:

http://www.powerbasic.com/support/forums/Forum4/HTML/013629.html

But the URL given doesn't appear to work.  Is it still available?  If not, what would you suggest as a good starting point for jumping in to build a function for parsing/evaluating an XML file?
Title: Re: XML
Post by: José Roca on February 05, 2015, 06:59:28 AM
TB_XML40 was an old library of wrapper functions to use MSXM when PB had no direct interface call support.

You can use MSXML or XMLLite. Both are COM technologies from Microsoft.

For XMLLite see: http://www.jose.it-berater.org/smfforum/index.php?topic=4237.0
Title: Re: XML
Post by: Bernard Ertl on February 06, 2015, 03:11:51 PM
Thanks José!  Based upon what I'm reading here:

https://msdn.microsoft.com/en-us/magazine/cc163436.aspx

It looks like XmlLite might be a leaner solution for my simple needs.
Title: Re: XML
Post by: Bernard Ertl on February 06, 2015, 03:21:58 PM
In the code linked in your post, you have:

#INCLUDE ONCE "shlwapi.inc"
#INCLUDE ONCE "ocidl.inc"
#INCLUDE ONCE "xmllite.inc"

Where can I find those .INC files?
Title: Re: XML
Post by: José Roca on February 07, 2015, 07:57:16 AM
They are part of my Windows API Headers package:
http://www.jose.it-berater.org/smfforum/index.php?topic=4985.0
Title: Re: XML
Post by: Bernard Ertl on February 11, 2015, 03:19:34 PM
Thanks José.  I've downloaded the headers and I tried compiling your sample code (EX_XmlLiteReader.bas).  PB complains that ITypeInfo is an undefined type in ocidl.inc.
Title: Re: XML
Post by: José Roca on February 11, 2015, 07:18:44 PM
You must have the paths for my include files and the path for the PB includes mixed in the PB IDE. You can't mix them.

Quote
You must also be aware that these headers are not extensions to the ones provided with the compiler, but a full replacement. Therefore, you must not mix them with the PowerBASIC include files in any way, neither directly (via #INCLUDE), nor indirectly (via the include path in the IDE).
Title: Re: XML
Post by: Bernard Ertl on February 12, 2015, 04:04:21 PM
I was hoping to add my XML processing code to a larger application that is well under development at the moment.  Any idea what issues I might encounter if I switched from PB's headers to your headers for my existing code?  Or would it be better to develop my XML code using your headers in a DLL [or static library] (to keep existing code using PB's headers)?
Title: Re: XML
Post by: Bernard Ertl on February 12, 2015, 06:21:51 PM
In your sample code, you use SHCreateStreamOnFile to open an input stream.  Your sample code simply ends when the file is processed, but if I'm processing a file in a function and not closing the app, do I need to call a function or something to close/release the stream when I'm done processing?
Title: Re: XML
Post by: José Roca on February 12, 2015, 08:30:33 PM
When done, use:

pFileStream = NOHING
pReader = NOTHING
Title: Re: XML
Post by: José Roca on February 12, 2015, 08:35:51 PM
Quote from: Bernard Ertl on February 12, 2015, 04:04:21 PM
I was hoping to add my XML processing code to a larger application that is well under development at the moment.  Any idea what issues I might encounter if I switched from PB's headers to your headers for my existing code?  Or would it be better to develop my XML code using your headers in a DLL [or static library] (to keep existing code using PB's headers)?

You can add %USEPBDECL = 1 before any #INCLUDE for compatibilty.

When I wrote my headers, the current PB ones did not exist. Besides, they lack any support for low level COM programming.