Good Morning.
does anyone know how to skip empty tags when exporting with a XmlPort?
I tryed to do that setting the MinOccurs property of the element to zero but does'nt work.
It's a great problem form me because my commitment don't accept empty tags.
Can somebody help me?
Thanks for all.
0
Comments
i had the same problem. solved it like that:
DeleteEmptyXMLNodes(VAR XMLNode : Automation "'Microsoft XML, v3.0'.IXMLDOMNode")
IF XMLNode.nodeTypeString = 'element' THEN BEGIN
IF (XMLNode.hasChildNodes = FALSE) THEN BEGIN
IF (XMLNode.xml = '<' + XMLNode.nodeName + '/>') THEN
XMLNode := XMLNode.parentNode.removeChild(XMLNode)
END ELSE BEGIN
XMLDomNodeList := XMLNode.childNodes;
FOR i := 1 TO XMLDomNodeList.length DO BEGIN
XMLChildNode :=XMLDomNodeList.nextNode();
DeleteEmptyXMLNodes(XMLChildNode);
END;
END;
END;
following local variables:
XMLChildNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
XMLDomNodeList Automation 'Microsoft XML, v3.0'.IXMLDOMNodeList
i Integer
you can use it with an existing xml-document like that:
CurrNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
CurrNode := XMLDOMDocument.documentElement;
DeleteEmptyXMLNodes(CurrNode);
hope this helps.
RIS Plus, LLC
I am trying this but I dont understand what taht is ;CurrNode := XMLDOMDocument.documentElement;
Thank you
RIS Plus, LLC
I followed exactly these instructions.
In the XML port, at the OnPostXMLport() trigger I call:
CurrNode := XMLDOMDocument.documentElement;
DeleteEmptyXMLNodes(CurrNode);
The function DeleteEmptyXMLNodes(CurrNode); is also in the XML port.
The XML port compiles well but during running I get the error (translated):
This message is for C/AL programmers:
Could not create a working copy of the Automation variable.
You can create a working copy by creating a variable or applying.
I reinstalled the client, NAV 4.0 SP3 native, with all options.
I reinstalled MSXML 3.0 SP7.
Tried also XML 4.0 and 6.0 but no improvement. ](*,)
Any suggestions?
I tried the code with the help of following builds:
NAV-Build SQL-Build Works
32275 (R2) 10.5…… (R2) No
31671 10.5…. (R2) No
32275 (R2) 10.0…. No
31671 10.0…. Yes
My theory was that it is a problem with some Update in late 2012, but if this problem already occurred in 2007 (axxion), it seems to be something different. Has anybody any ideas? I doublechecked the NAV objects in the above databases.
(I do not use the code directly in an xmlPort, but I save a xmlport-Export as a BLOB in a table; later I load the BLOB in a xmldom Document - Variable; after that, I go on with the proposed code)
edit: okay the reason has to be that I mess up my BLOB in my table somehow, because it only fails when I try to process the BLOB more than once.
See <Ctry/> Node... Strange!!!
How can i skip Empty Nodes, and how a particular Node, for example only "Ctry" empty nodes. I suppose asking about XMLNode.nodeName = 'Ctry' but i have same result...
Actually result is:
But i need this format:
:roll:
BR
I am trying to use this function to remove empty XML Tags on NAV2013. So I have changed everything from automation to DotNet. But I am facing a problem whereby I cannot parse the XMLNode to the function DeleteEmptyXMLNodes().
Error Message is:
Microsoft Dynamics NAV
A DotNet variable has not been instantiated. Attempting to call MSXML.IXMLDOMNode.nodeTypeString in Report SI: XML Invoice Export: DeleteEmptyXMLNodes
OK
Main Body CU...
DeleteEmptyXMLNodes function...
There is a work around? I need a solution for SaaS..