Author Topic: XML  (Read 9840 times)

0 Members and 1 Guest are viewing this topic.

Offline Bernard Ertl

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +0/-5
  • Gender: Male
    • InterPlan Systems
XML
« 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?

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2530
  • User-Rate: +209/-0
  • Gender: Male
Re: XML
« Reply #1 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

Offline Bernard Ertl

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +0/-5
  • Gender: Male
    • InterPlan Systems
Re: XML
« Reply #2 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.

Offline Bernard Ertl

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +0/-5
  • Gender: Male
    • InterPlan Systems
Re: XML
« Reply #3 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?

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2530
  • User-Rate: +209/-0
  • Gender: Male
Re: XML
« Reply #4 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

Offline Bernard Ertl

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +0/-5
  • Gender: Male
    • InterPlan Systems
Re: XML
« Reply #5 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.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2530
  • User-Rate: +209/-0
  • Gender: Male
Re: XML
« Reply #6 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).

Offline Bernard Ertl

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +0/-5
  • Gender: Male
    • InterPlan Systems
Re: XML
« Reply #7 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)?

Offline Bernard Ertl

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +0/-5
  • Gender: Male
    • InterPlan Systems
Re: XML
« Reply #8 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?

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2530
  • User-Rate: +209/-0
  • Gender: Male
Re: XML
« Reply #9 on: February 12, 2015, 08:30:33 PM »
When done, use:

pFileStream = NOHING
pReader = NOTHING

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2530
  • User-Rate: +209/-0
  • Gender: Male
Re: XML
« Reply #10 on: February 12, 2015, 08:35:51 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.