Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-07

XML: how to change first line?

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi list,

I'm writing XML export for datasets using the XMLWrite and DOM units (as per documentation at http://wiki.lazarus.freepascal.org/XML_Tutorial) I've got this snippet:
FOutputDoc := TXMLDocument.Create;

How do I change the first line of the generated XML output from <?xml version="1.0">
to
<?xml version="1.0" standalone="yes"?>

I tried adding an attribute like this:
TDOMElement(FOutputDoc.DocumentElement).SetAttribute(

      'standalone', UTF8Decode('yes'));

but that gave an access violation: DocumentElement property is read-only...

Thanks,
Reinier

Michael Van Canneyt
to Reinier Olislagers
Reinier Olislagers wrote 16 lines
Hi list, I'm writing XML export for datasets using the XMLWrite and DOM units (as per documentation at http://wiki.lazarus.freepascal.org/XML_Tutorial) I've got this snippet: FOutputDoc := TXMLDocument.Create; How do I change the first line of the generated XML output from <?xml version="1.0"> to <?xml version="1.0" standalone="yes"?> I tried adding an attribute like this: TDOMElement(FOutputDoc.DocumentElement).SetAttribute( 'standalone', UTF8Decode('yes')); but that gave an access violation: DocumentElement property is read-only...

I don't think that currenly there is a way to set this attribute ?

Unless Sergei Gorelkin knows a way, we'll have to adapt the fpdoc package.

In each case, the 'standalone' attribute is not valid XML according to:

http://www.w3.org/TR/xml/#NT-S

So I don't think you should bother adding that. Probably some M$ specific addition.

Michael.

Reinier Olislagers
to Michael Van Canneyt
Michael Van Canneyt wrote 20 lines
On Sun, 24 Jul 2011, Reinier Olislagers wrote: > <?xml version="1.0" standalone="yes"?> > I tried adding an attribute like this: > TDOMElement(FOutputDoc.DocumentElement).SetAttribute( > 'standalone', UTF8Decode('yes')); > but that gave an access violation: DocumentElement property is > read-only... I don't think that currenly there is a way to set this attribute ? Unless Sergei Gorelkin knows a way, we'll have to adapt the fpdoc package. In each case, the 'standalone' attribute is not valid XML according to: http://www.w3.org/TR/xml/#NT-S So I don't think you should bother adding that. Probably some M$ specific addition. Michael.

Thanks Michael,

Had a look at the specification link you sent, I don't get it (that part deals with valid spaces in nodes?).
I did see this:
http://www.w3.org/TR/xml/#NT-SDDecl
Standalone Document Declaration
....
An example XML declaration with a standalone document declaration:

<?xml version="1.0" standalone='yes'?>

Anyway, I'll leave it be and try if it imports without that addition. If it doesn't, I'll get back on the list & bug tracker.

Reinier