[fpc-pascal] DOM and namespaces with prefix

Daniel Gaspary dgaspary at gmail.com
Sat Jun 23 01:01:24 CEST 2012


On Tue, Jun 19, 2012 at 10:11 AM, Torsten Bonde Christiansen
<tc at epidata.info> wrote:
>  DDIInstance := XMLDoc.CreateElementNS('ddi:instance:3_0', 'DDIInstance');
>  DDIInstance.Prefix := 'ns1';        // this gives me: <ns1:DDIInstance
> xmlns:ns1="ddi:instance:3_0"> which is great.
>
>  // now I would like to expand with eg: xmlns:a="ddi:archive:3_0"
>  Attr := XMLDoc.CreateAttributeNS('ddi:archive:3_0', 'huh');
>  Attr.Prefix := 'a';
>  DDIInstance.SetAttributeNode(Attr);   // but this gives: <ns1:DDIInstance
> xmlns:ns1="ddi:instance:3_0" xmlns:a="ddi:archive:3_0" a:huh=""/>

> How can i get the "xmlns:a="ddi:archive:3_0" without the additional
> attribute AND maintain the namespace + prefix in later elements?

I believe that the solution(given by Sergei Gorelkin at [1]) is:

DDIInstance.SetAttributeNS('ddi:archive:3_0','xmlns:a','ddi:archive:3_0');

[1] http://bugs.freepascal.org/view.php?id=22299#c60652



More information about the fpc-pascal mailing list