XML Prefix via XML DOM

DjawadiDjawadi Member Posts: 3
Hello,

I am trying to create an XML-File via XML Dom.
All Tags need to have a prefix in it. And that is where I am stuck at the moment.

Here is the example code:
IF ISCLEAR(XMLDocOut) THEN
  CREATE(XMLDocOut,TRUE);

XMLDocOut.async := FALSE;
XMLDocOut.validateOnParse := FALSE;
XMLDocOut.resolveExternals := FALSE;


XMLDocOut.loadXML(Text1140008+'<Tool.message.0300></Tool.message.0300>');

IF XMLDocOut.xml = '' THEN
  ERROR(LocText004);

XMLCurrNode := XMLDocOut.documentElement;

XMLDOMManagement.SetNormalCase;

XMLDOMManagement.AddAttribute(XMLCurrNode,'xmlns:prefixname','http://valid-url');
XMLDOMManagement.AddAttribute(XMLCurrNode,'prefixname:version','1.2');
XMLDOMManagement.AddAttribute(XMLCurrNode,'prefixname:fassung','2008-12-12');
XMLDOMManagement.AddAttribute(XMLCurrNode,'xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
XMLDOMManagement.AddAttribute(XMLCurrNode,'xsi:schemaLocation','http://validurl' + ' ' +
'http://validurl.xsd');

IF NOT RecContact.GET(Kontaktnr) THEN
  ERROR(LocText003,Kontaktnr);

WITH XMLDOMManagement DO BEGIN
  IF AddElement(XMLCurrNode,'prefixname:time',TIME,'',XMLNewChild) > 0 THEN
    EXIT;

Now I get an Error "not declared prefix: prefixname"
Any Ideas on that? I am happy for any advice.

Rene


/Update:
If I user the line
IF AddElement(XMLCurrNode,'prefixname:time',TIME,prefixname,XMLNewChild) > 0 THEN

I don't get an error, but the Tag in the XML-File looks like:
<prefixname:time xmlns:prefixname = prefixname>

But I need it to look like:
<prefixname:time>

Comments

  • DjawadiDjawadi Member Posts: 3
    Ok I got it myself.
    Here is the solution:
    IF AddElement(XMLCurrNode,'prefixname:time',TIME,http://validurl,XMLNewChild) > 0 THEN
    
Sign In or Register to comment.