Options

Add namespace prefix to every node when exporting XML?

TiwazTiwaz Member Posts: 98
edited 2016-11-18 in NAV Tips & Tricks
Hi everyone.
I want to have, instead of this:
<PodaciPoreskeDeklaracije xmlns='http://pid.purs.gov.rs'&gt;
<PodaciOPrijavi>
<VrstaPrijave>1</VrstaPrijave>
<ObracunskiPeriod>2016-10</ObracunskiPeriod>
<DatumDospelostiObaveze>2016-01-05</DatumDospelostiObaveze>
.
.
.


THIS
<ns1:PodaciPoreskeDeklaracije
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns1='http://pid.purs.gov.rs'&gt;
<ns1:PodaciOPrijavi>
<ns1:VrstaPrijave>1</ns1:VrstaPrijave>
<ns1:ObracunskiPeriod>2016-10</ns1:ObracunskiPeriod>
<ns1:DatumDospelostiObaveze>2016-01-05</ns1:DatumDospelostiObaveze>
.
.
.
.
How can I add this ns1: prefix to each element and how can I insert xsi schema namespace too?
I added http://pid.purs.gov.rs in namespace property but that does just this: xmlns='http://pid.purs.gov.rs'
THANKS :)

Answers

  • Options
    vremeni4vremeni4 Member Posts: 323
    Hmm the problem is you did not say what version of NAV is it.

    In NAV 2016 and later versions you can use NamespacePrefix property In XML port.
    In NAV 2013 R2 - NAV 2015 with an XMLport you cna just create the file as above, and then run a separate routine to read the XMlfile and add the a name space.
    (I am not aware of any other options)

    In NAV 2009 you have to use the codeunit "XML DOM Management" to create the XMl file. With XMLPorts you will not get very far.

    In general for all NAV versions you could use the codeunit "XML DOM Management" to create the XMl file and forget the XMLport, but this is a bit more work.

    I hope this helps
    Thanks.
Sign In or Register to comment.