XML

Started by Bernard Ertl, February 04, 2015, 03:31:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bernard Ertl

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?

José Roca

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

Bernard Ertl

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.

Bernard Ertl

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?

José Roca


Bernard Ertl

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.

José Roca

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).

Bernard Ertl

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)?

Bernard Ertl

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?

José Roca

When done, use:

pFileStream = NOHING
pReader = NOTHING

José Roca

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.