XML API: How to load text into an XmlCode, then append to another node

gatsby0121
Member Posts: 13
I'm loading using LoadXMLNodeFromText to create an xmlnode from a string, then add it to another element using XML Dom Mgt.AddElement.
However, when I write the results to a text string, the text that I loaded into the XmlNode is not there. This is my procedure, is there something I'm missing?
However, when I write the results to a text string, the text that I loaded into the XmlNode is not there. This is my procedure, is there something I'm missing?
procedure CreateBody(var pSoapEnvelope: XmlNode; var pSoapBody: XmlNode; pVersion: Option "1.1","1.2"; var reqText: Text); var lSoapDataNode: XmlNode; textString: Text; begin if pVersion = pVersion::"1.1" then XMLDOMMgt.AddElement(pSoapEnvelope, 'Body', '', SoapNS11, pSoapBody) else XMLDOMMgt.AddElement(pSoapEnvelope, 'Body', '', SoapNS12, pSoapBody); XMLDomMgt.LoadXMLNodeFromText(reqText, lSoapDataNode); XMLDOMMgt.AddElementWithPrefix(pSoapBody, 'CV3Data', '', SoapPrefix, 'SoapNamespaceTxt', pSoapBody); //xx01 XMLDOMMgt.AddElement(pSoapBody, 'data', reqText, '', lSoapDataNode); end;
0
Answers
-
I think there was a bug in the xml dom mgt c/al to al rewrite by Divesh Bora, where the addelement method was adding the nodetext to the new node if it was blank. I changed the check to <> instead and it's now working.0
-
Hi.
I think you should use AddElementToNode() instead of AddElement() in this case.
AddElement() creates new node and you lose result of LoadXMLNodeFromText().XMLDOMMgt.AddElementWithPrefix(pSoapBody, 'CV3Data', '', SoapPrefix, 'SoapNamespaceTxt', pSoapBody); XMLDomMgt.LoadXMLNodeFromText(reqText, lSoapDataNode); XMLDOMMgt.AddElementToNode(pSoapBody,lSoapDataNode,'',CreatedXMLNode);
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