Parts of XML Namespace copying down to next child Node.....

leegeorgeHughesleegeorgeHughes Member Posts: 26
Hi - Hope someone can help me - im banging my head against a brick wall...... ](*,) ](*,) ](*,)

I am trying to generate an XML file from NAV using the XML Management Codeunit (6224)

I have got my head around traversing the different levels of nodes but there is one thing that i cannot seem to get sorted.

The XML file i need to create (see sample below)has has "headings" which I have called the addelement function to create - the element gets created but then it has the beginning of a namespace which i don't want.

Here is what the file should look like

<?xml version="1.0"?>
<importDeclaration xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns="asm.org.uk/Sequoia/DeclarationGbImport">
<declarantBadge>
<code xmlns="asm.org.uk/Sequoia/Badge">DRB</code>
<location xmlns="asm.org.uk/Sequoia/Badge">
<iataPortCode xmlns="asm.org.uk/Sequoia/UnLocation">LHR</iataPortCode>
</location>
</declarantBadge>
<declarationCurrency>
<currencyCode xmlns="asm.org.uk/Sequoia/Currency">GBP</currencyCode>
</declarationCurrency>

Here is the file I created - Note the addional values against DeclarantBadge and DeclarantCurrency

<?xml version="1.0"?>
<importDeclaration xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns="asm.org.uk/Sequoia/DeclarationGbImport">
<declarantBadge xmlns="">
<code xmlns="asm.org.uk/Sequoia/Badge">DRB</code>
<location xmlns="asm.org.uk/Sequoia/badge">
<iataportCode xmlns="asm.org.uk/Sequoia/UnLocation">LHR</iataportCode>
</location>
</declarantBadge>
<declarationCurrency xmlns="">
<currencyCode xmlns="asm.org.uk/Sequoia/Currency">GBP</currencyCode>
</declarationCurrency>
</importDeclaration>


Here is the code I am using to generate the file


CREATE(xmlDoc);
xmlMgt.SetNormalCase;
xmlProcessingInst:=xmlDoc.createProcessingInstruction('xml','version="1.0"');
CurrNode := xmlDoc.appendChild(xmlProcessingInst);
CurrNode := xmlDoc.createElement('importDeclaration');
CurrNode := xmlDoc.appendChild(CurrNode);
xmlMgt.SetNormalCase;
xmlMgt.AddAttribute(CurrNode,'xmlns:xsd','http://www.w3.org/2001/XMLSchema');
xmlMgt.AddAttribute(CurrNode,'xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
xmlMgt.AddAttribute(CurrNode,'xmlns','asm.org.uk/Sequoia/DeclarationGbImport');
xmlMgt.AddElement(CurrNode,'declarantBadge','','',NewChild);
CurrNode1:=NewChild;
xmlMgt.AddElement(CurrNode1,'code','DRB','asm.org.uk/Sequoia/Badge',NewChild);
xmlMgt.AddElement(CurrNode1,'location','','',NewChild);
CurrNode1:=NewChild;
xmlMgt.AddAttribute(CurrNode1,'xmlns','asm.org.uk/Sequoia/badge');
CurrNode1:=NewChild;
xmlMgt.AddElement(CurrNode1,'iataportCode','LHR','',NewChild);
CurrNode1:=NewChild;
xmlMgt.AddAttribute(CurrNode1,'xmlns','asm.org.uk/Sequoia/UnLocation');
xmlMgt.AddElement(CurrNode,'declarationCurrency','','',NewChild);
CurrNode:=NewChild;
xmlMgt.AddElement(CurrNode,'currencyCode','GBP','',NewChild);
CurrNode:=NewChild;
xmlMgt.AddAttribute(CurrNode,'xmlns','asm.org.uk/Sequoia/Currency');

I have read a post where someone said there are odd things with XML v3 so Ive updated all globals and locals to XML6 and still have the issue.

Any help/advice would be greatly appreciated...
Sign In or Register to comment.