I wrote some code to create an xml-file with XML-Dom in Navision 2009 SP1.
Till here, this is nothing special. The problem is, that every time I add an attribute to a node it will create a empty attribute on the next element.
<?xml version="1.0" encoding="ISO-8859-1"?>
<DeclareSalary xmlns="
http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationServiceTypes">
<RequestContext xmlns="
http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer">
<UserAgent xmlns=""/><CompanyName xmlns=""/>
</RequestContext>
</DeclareSalary>
What can I do that these empty attributes will not occur? Does anybody has a idea?
No, i cannot create it with XML-Ports.... the code is to complex to simly use an xml port.
Thanks
Patrick
Comments
<UserAgent xmlns=""/>
<CompanyName xmlns=""/>
these attributes?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
IF cNamespaceIn <> '' THEN BEGIN
rNameSpaceLoc.GET(cNamespaceIn);
autElementVar := autXMLDoc.createNode(1,tNameIn,rNameSpaceLoc.URI);
END ELSE
autElementVar := autXMLDoc.createNode(1,tNameIn,'');
IF tDataIn <> '' THEN
autElementVar.text := tDataIn;
autParentIn.appendChild(autElementVar);
In this case the value in tDataIn is always empty... so only the functions createNode and appendChild will be called.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
That's not possible, because I need this element... but not the empty attribute.
The original code to set the attribut looks like this:
IF rLineIn.Namespace <> '' THEN BEGIN
rNameSpaceLoc.GET(rLineIn.Namespace);
tAttrNameLoc := 'xmlns';
autParentIn.setAttribute(tAttrNameLoc,rNameSpaceLoc.URI);
CLEAR(rNameSpaceLoc);
END;
this creates the following XML-File:
<DeclareSalary xmlns="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationServiceTypes">
<RequestContext xmlns="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer">
<UserAgent xmlns="">
<Producer>Microsoft Corporation</Producer>
<Name>Microsoft Dynamics NAV</Name>
But if I change the code like this:
IF rLineIn.Namespace <> '' THEN BEGIN
rNameSpaceLoc.GET(rLineIn.Namespace);
tAttrNameLoc := 'xmlnsx';
autParentIn.setAttribute(tAttrNameLoc,rNameSpaceLoc.URI);
CLEAR(rNameSpaceLoc);
END;
the XML-File looks like this:
<DeclareSalary xmlnsx="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationServiceTypes">
<RequestContext xmlnsx="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer">
<UserAgent>
<Producer>Microsoft Corporation</Producer>
<Name>Microsoft Dynamics NAV</Name>
This will be how it looks like, with exception of the attribut
Patrick