Store MSXML in a Database

forum.advanced.programming (1998-2005)
Tino

Store MSXML in a Database

Post by Tino » 11 Jan 2005, 17:39

 Posted by:  Tino 

Hi Ng,

we have a Problem with XML ( UTF-8 ) and a Database...

We create a XML-Object with MSXML. It works good.
We kann save it to disk and it is possible to read it with
Internet-Explorer.

The next step should be: Save this XML-File in the database... ( the
tablecolumn is binary )

There are two questions:

- Which kind of Bindvariable from CTD is possible ( LONGSTRING ? )
- Which way from from MSXML to the Bindvariable is possible
( Set Bindvar = MSXML... or save MSXML and load the File with
SalFileRead in the Bindvar )

Many Thanks

Tino

SurenBehari
United States of America
Posts: 305
Joined: 12 Apr 2021, 14:50
Location: Santa Clara, US

Re: Store MSXML in a Database

Post by SurenBehari » 12 Jan 2005, 01:38

 Posted by:  Suren Behari 

Hi,

Option 1 - XML as an external file
Use SalFileOpen with OF_Binary & OF_Read, and read the contents into a Long
String variable, that can be used as a bind variable for saving into a
database.

Option2 - XML created within Team Developer
Use the function PropGetxml( long string variable) of your instance of the
DOMDocument object to populate the variable to be used as the bind for
saving to the database.

Thanks,
Suren

Lubos Vnuk

Re: Store MSXML in a Database

Post by Lubos Vnuk » 12 Jan 2005, 14:21

 Posted by:  Lubos Vnuk 

If you are using extended characters (anything above US-ASCII) from UTF-8
you may run into problems when relying on PropGetxml(). I recommend you use
the long way via a temporary file storage.

Regards,
Lubos.

When dealing with XML character encoding, you should understand what happens
behind the scenes:
- Team Developer using native strings (null terminated 8-bit character
strings)
- TD COM support passing strings to MSXML (conversion to 2-byte Unicode COM
BSTRs ).
- MSXML processing DOM internally (Unicode BSTR)
- MSXML passing the XML strings back to TD COM support (Unicode BSTR =>
thus no encoding attribute)

So the encoding attribute can actually be inserted successfully, it will
just not appear within the XML string property (PropGetxml) as such. If you
do not believe, try using the XMLDocument's save() method and see for
yourself. MSXML will perform the conversion to the desired encoding
automatically.

Return to “advanced.programming”

Who is online

Users browsing this forum: [Ahrefs], [Ccbot] and 0 guests