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

leegeorgeHughes
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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...
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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...
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions