Sign in Join

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

Mailing lists / fpc-pascal / 2011-10

XML - How to set and use a Namespace Prefix?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Daniel Gaspary

I'm trying to create an XML Document with multiple Namespaces.

With the code below[1] a get as result the following XML:

<svg xmlns="http://www.w3.org/2000/svg" />

How can I set a second Namespace, should I use SetAttribute or SetAttributeNS ? :

root.setattribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');

?

Can anybody give me an example when setAttributeNS is useful ?

Is there a way to, after setting a namespace prefix, make all attributes and elements to be added using it ?

Thanks

[1]
var
   Doc: TXMLDocument;
   root, node: TDOMElement;
begin
     Doc:=TXMLDocument.Create;
     root:=Doc.CreateElementNS('http://www.w3.org/2000/svg', 'svg');
     Doc.AppendChild(root);
...
end;

Reply by email