XMLPORT:Skip Empty Tags

pgroppuso
Member Posts: 2
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.
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
-
Hi,
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.0 -
-
Hello
I am trying this but I dont understand what taht is ;CurrNode := XMLDOMDocument.documentElement;
Thank you0 -
The documentelement is the root element of the XML document. CurrNode is the node that you are currently looking at. That code puts the root element of the XML document into the CurrNode variable0
-
Hi All,
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?0 -
I used the code provided by bluesky29 for two years (was used only in the beginning of every year but very often then) and now I have the same problem as axxion (Post above).
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.0 -
bluesky29 wrote: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;<PstlAdr> <StrtNm>STREET, 1</StrtNm> <PstCd>01234</PstCd> <TwnNm>TOWN</TwnNm> <Ctry/> </PstlAdr>
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:<Cdtr> <Nm>NAME</Nm> <PstlAdr> <TwnNm/> </PstlAdr> </Cdtr>
But i need this format:<Cdtr> <Nm>NAME</Nm> <PstlAdr> </PstlAdr> </Cdtr>
:roll:
BR0 -
Hi,
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...XMLDomDocument := XMLDomConstructor.DOMDocumentClass; XMLDomDocument.loadXML(ServerFileName); CurrNode := XMLDomDocument.documentElement; DeleteEmptyXMLNodes(CurrNode); XMLDomDocument.save(ServerFileName);
DeleteEmptyXMLNodes function...DeleteEmptyXMLNodes(VAR XMLNode : DotNet "MSXML.IXMLDOMNode") IF XMLNode.nodeTypeString = 'element' THEN BEGIN IF (XMLNode.hasChildNodes = FALSE) THEN BEGIN IF (XMLNode.xml = '<' + XMLNode.nodeName + '/>') THEN XMLNode := XMLNode.parentNode.removeChild(XMLNode) ELSE BEGIN XMLDomNodeList := XMLNode.childNodes; FOR i := 1 TO XMLDomNodeList.length DO BEGIN XMLChildNode :=XMLDomNodeList.nextNode(); DeleteEmptyXMLNodes(XMLChildNode); END; END; END; END;
0 -
The easy way is to use CurrXMLport.skip insinde the Export::OnBeforePassVariable() trigger. If MyNode = '' then CurrXmlPort.Skip and the node is not created.0
-
The easy way is to use CurrXMLport.skip insinde the Export::OnBeforePassVariable() trigger. If MyNode = '' then CurrXmlPort.Skip and the node is not created.
There is a work around? I need a solution for SaaS..
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