<?xml version="1.0" encoding="UTF-8" ?> <foo-0001:envelope version="1.0" xmlns:foo-0001="http://www.foo.com/xmlns/foo-0001/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <messageId>1234</messageId> </foo-0001:envelope>
CREATE(xmlDoc); xmlMgt.SetNormalCase; xmlProcessingInst:=xmlDoc.createProcessingInstruction('xml','version="1.0" encoding="UTF-8"'); CurrNode := xmlDoc.appendChild(xmlProcessingInst); CurrNode := xmlDoc.createElement('foo-0001:envelope'); CurrNode := xmlDoc.appendChild(CurrNode); xmlMgt.AddAttribute(CurrNode,'version','1.0'); xmlMgt.AddAttribute(CurrNode,'xmlns:foo-0001','http://www.foo.com/xmlns/foo-0001/1'); xmlMgt.AddAttribute(CurrNode,'xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance'); xmlMgt.AddElement(CurrNode,'messageId','1234','',NewChild);
xmlMgt.AddElement(CurrNode,'foo-0001:messageId','1234','',NewChild);I get the error "Reference to undeclared namespace prefix 'foo-0001'.
Comments
In cu6224, function AddElement it's better to use "createElement" instead of "createnode".
(Of course I use now a copy of the AddElement-Function.)
Hope this may be helpful for someone else.
Regards
Thomas