Adding <!DOCTYPE> in xml

Posted by ankitshukla on 17-Mar-2016 03:56

Hi,

I wanted to add the following tag into my xml

<!DOCTYPE ndxml PUBLIC "-//NETDESPATCH//ENTITIES/Latin" "ndentity.ent">

Can any one let me know if it is possible through progress 4gl code.

Thanks,
Ankit

All Replies

Posted by Alex Herbstritt on 17-Mar-2016 07:38

For DOM you would use INITIALIZE-DOCUMENT-TYPE.

Here is an example:

define variable refxml  as handle no-undo.
define variable refroot as handle no-undo.
define variable refnode as handle no-undo.

create x-document refxml.
create x-noderef  refroot.
create x-noderef  refnode.

/* <!DOCTYPE ndxml PUBLIC "-//NETDESPATCH//ENTITIES/Latin" "ndentity.ent"> */
refxml:INITIALIZE-DOCUMENT-TYPE
  ("", "ndxml", "-//NETDESPATCH//ENTITIES/Latin", "ndentity.ent").
  
refxml:CREATE-NODE(refroot,"root","ELEMENT").
refxml:APPEND-CHILD(refroot).

refxml:CREATE-NODE(refnode,"child","ELEMENT").
refroot:APPEND-CHILD(refnode).

refxml:SAVE("file","example.xml").

Here is the output:

<?xml version="1.0" ?>
<!DOCTYPE ndxml PUBLIC "-//NETDESPATCH//ENTITIES/Latin" "ndentity.ent"><ndxml/>

Posted by ankitshukla on 17-Mar-2016 10:16

Thanks Alex!!! It's really helpful.

This thread is closed