Import [CDATA[ into BLOB using XMLDom
TheDoubleH
Member Posts: 67
Due to the limitations in XMLPorts, I had to create a manual import using Automation but I have a problem importing a [CDATA[ element.
Could anyone shed some light on how I can get that accomplished?
I have the following code: (it may not be pretty, but it works - in my 15 years doing NAV I have not had to do this :oops: )
Could anyone shed some light on how I can get that accomplished?
I have the following code: (it may not be pretty, but it works - in my 15 years doing NAV I have not had to do this :oops: )
CREATE(PageXMLFile,TRUE,TRUE);
PageXMLFile.load('c:\Temp\ItemCard.xml');
XMLPageNodeList := PageXMLFile.selectNodes('/Objects/Page');
FOR z := 1 TO XMLPageNodeList.length DO BEGIN
PageObject.INIT;
// Yes I know, that I need to create a function for this ;)
XMLCurrentNode := XMLPageNodeList.nextNode;
XMLAttribute := XMLCurrentNode.selectSingleNode(STRSUBSTNO('@%1','ID'));
EVALUATE(PageObject.ID,XMLAttribute.text);
XMLAttribute := XMLCurrentNode.selectSingleNode(STRSUBSTNO('@%1','Name'));
PageObject.Name := XMLAttribute.text;
XMLAttribute := XMLCurrentNode.selectSingleNode(STRSUBSTNO('@%1','Date'));
EVALUATE(DayNo,COPYSTR(XMLAttribute.text,9,2));
EVALUATE(MonthNo,COPYSTR(XMLAttribute.text,6,2));
EVALUATE(YearNo,COPYSTR(XMLAttribute.text,1,4));
PageObject.Date := DMY2DATE(DayNo,MonthNo,YearNo);
//Need to deal with the date
//XMLAttribute := XMLCurrentNode.selectSingleNode(STRSUBSTNO('@%1','Time'));
//EVALUATE(PageObject.Time,XMLAttribute.text);
XMLAttribute := XMLCurrentNode.selectSingleNode(STRSUBSTNO('@%1','VersionList'));
PageObject."Version List" := XMLAttribute.text;
IF NOT PageObject.INSERT THEN
PageObject.MODIFY;
XMLGroupNodeList := XMLCurrentNode.selectNodes('./Controls/ContentArea/Group');
[color=#BF0000]//
// THIS is what I need to import into my blob!
//
XMLCodeNode := XMLCurrentNode.selectSingleNode('./Code');[/color]
FOR j := 1 TO XMLGroupNodeList.length DO BEGIN
XMLCurrentNode := XMLGroupNodeList.nextNode;
XMLFieldNodeList := XMLCurrentNode.selectNodes('Field');
FOR i := 1 TO XMLFieldNodeList.length DO BEGIN
XMLCurrentNode := XMLFieldNodeList.nextNode;
XMLFieldPropertyNodeList := XMLCurrentNode.selectNodes('Properties');
//IF NOT CONFIRM(XMLCurrentNode.xml,FALSE) THEN
// ERROR('');
//IF NOT CONFIRM(FORMAT(XMLCurrentNode.nodeName),FALSE) THEN
// ERROR('');
PageObjectControl.INIT;
PageObjectControl."Page ID" := PageObject.ID;
FOR x := 1 TO XMLFieldPropertyNodeList.length DO BEGIN
XMLCurrentNode := XMLFieldPropertyNodeList.nextNode;
XMLFieldPropertiesNodeList := XMLCurrentNode.childNodes;
FOR y := 1 TO XMLFieldPropertiesNodeList.length DO BEGIN
XMLCurrentNode := XMLFieldPropertiesNodeList.nextNode;
CASE XMLCurrentNode.nodeName OF
'ID' : EVALUATE(PageObjectControl.ID,XMLCurrentNode.text);
'SourceExpr' : PageObjectControl."Source Expression" := XMLCurrentNode.text;
'Visible' :
BEGIN
PageObjectControl."Visible Exists" := TRUE;
PageObjectControl.Visible := XMLCurrentNode.text;
END;
'HideValue' :
BEGIN
PageObjectControl."HideValue Exists" := TRUE;
PageObjectControl.HideValue := XMLCurrentNode.text;
END;
'Importance' : EVALUATE(PageObjectControl.Importance,XMLCurrentNode.text);
END;
END;
IF NOT PageObjectControl.INSERT THEN
PageObjectControl.MODIFY;
END;
END;
END;
END;
0
Comments
-
Here is an example to retrieve the value of a CDATA-tag by a simple xpath-query.
CREATE(xmldom); xmldom.setProperty('SelectionNamespaces','xmlns:ns="urn:schemas-microsoft-com:dynamics:NAV:ApplicationObjects"'); xmldom.load('c:\temp\itemcard.xml'); node := xmldom.selectSingleNode('/ns:Objects/ns:Page/ns:Triggers/ns:OnInit'); IF NOT ISCLEAR(node) THEN MESSAGE('%1', node.text);0 -
Try to use 'Microsoft XML, v3.0'.IXMLDOMText instead of 'Microsoft XML, v3.0'.IXMLDOMNode. It has a substingData method that you can use to reading contents of the CDATA section. Also check this How to read XML data where all fields in single string ? topic.Looking for part-time work.
Nav, T-SQL.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
- 323 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