Board index » delphi » Manual XML generation with IMXWriter / SAX

Manual XML generation with IMXWriter / SAX

Hello

I am using CoMXWriter from MSXML2.dll to generate XML by casting
it as ISAXContentHandler and calling appropriate events on this
interface, e.g:

------

MXWriter := CoMXXMLWriter.Create;
SAXContHandler := MXWriter as IVBSAXContentHandler;

..

with SAXContHandler do
begin
{ Generate header }
  StartDocument;

{ Output an element }
  StartElement(WideString1, WideString2, WideString3, Attrs);
  ...
end;

{ Show output }
ShowMessage(MXWriter.Output);

------

When I try to invoke StartElement, I get the following error:

'The parameter is incorrect'.

Now, I realize one of the parameters is incorrect, but
there is no indication which one it is. Furthermore, this method
only takes 3 WideStrings and an ISAXAttributes interface. I
believe I am creating the ISAXAttributes interface correctly,
and have also tried passing in nil, which it should accept.

I would like to hear from anybody that has had success generating
XML in this manner, or who might have a clue what is wrong. It
should be something simple that I have missed.

Regards

Edward Garson
Software Developer
Channel 4 Television Corporation
London, England

 

Re:Manual XML generation with IMXWriter / SAX


Looks like MSXML is picky about BSTRs that come in as NULL. Delphi does not
allocate blank BSTRs/WideStrings. As a workaround, just use a single space
string (' ') for the parameters that you want to be blank strings.

--
have fun
Binh Ly
www.techvanguards.com

Quote
"Edward Garson" <egarson@[not> wrote in message news:3b055984$1_1@dnews...
>   StartElement(WideString1, WideString2, WideString3, Attrs);

> When I try to invoke StartElement, I get the following error:

> 'The parameter is incorrect'.

Other Threads