<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Nav developer's blog : XML</title><link>http://blogs.msdn.com/nav_developer/archive/tags/XML/default.aspx</link><description>Tags: XML</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Converting company names for NAV Web Services</title><link>http://blogs.msdn.com/nav_developer/archive/2009/07/10/converting-company-names-for-nav-web-services.aspx</link><pubDate>Fri, 10 Jul 2009 21:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9828963</guid><dc:creator>scowri</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/nav_developer/comments/9828963.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nav_developer/commentrss.aspx?PostID=9828963</wfw:commentRss><description>&lt;P&gt;A few weeks ago I saw an up tick in the number of cases having problems accessing exposed web service. Some of the problem has been because the “CRONUS USA, Inc.” company name converts to an unfamiliar “CROUNS_USA_x002C__Inc”. This will be &lt;A href="http://blogs.msdn.com/freddyk/archive/2009/05/27/web-services-changes-in-nav-2009-sp1.aspx" mce_href="http://blogs.msdn.com/freddyk/archive/2009/05/27/web-services-changes-in-nav-2009-sp1.aspx"&gt;changing in NAV 2009 SP1&lt;/A&gt;, but until that time it would be helpful to know exactly how company names are converted for NAV Web Services. The rules are: &lt;/P&gt;
&lt;P&gt;The character '%' are converted to the word “Percent”.&lt;/P&gt;
&lt;P&gt;The characters '@', '"', '.', '/', '(', ')', '\', '-', ' ' (blank space) are converted to “_” with the following two additional rules. &lt;/P&gt;
&lt;P&gt;- no two succeeding “_”’s &lt;BR&gt;- no trailing “_”&amp;nbsp; &lt;/P&gt;
&lt;P&gt;This covers most cases and only applies when replacing the above characters, not with the following "special characters". &lt;/P&gt;
&lt;P&gt;Any remaining “special characters” are converted to “a valid XML name” (basically a numeric value, for example, the ampersand ‘&amp;amp;’&amp;nbsp; are converted to “_x0026_”). When a "special character" is converted like this, you could have two succeeding underscores ('_'). &lt;/P&gt;
&lt;P&gt;List of known special characters (please update as needed.):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The ampersand ‘&amp;amp;’&amp;nbsp; are converted to “_x0026_” &lt;/LI&gt;
&lt;LI&gt;The comma ',' is converted to “_x002C_” (i.e. 'CRONUS USA, Inc.' would be converted to 'CRONUS_USA_x002C__Inc') &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Additional, the &lt;A href="http://msdn.microsoft.com/en-us/library/dd355012.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd355012.aspx"&gt;How-To “Use SystemService to Find Companies”&lt;/A&gt; in the &lt;A href="http://msdn.microsoft.com/en-us/library/dd448639.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd448639.aspx"&gt;NAV 2009 Developer and IT Pro Documentation&lt;/A&gt; explain how to call the Companies operation on the SystemService to list the available companies with the converted names. &lt;/P&gt;
&lt;P&gt;Scott Wright&lt;/P&gt;
&lt;P&gt;Microsoft Dynamics North America&lt;/P&gt;
&lt;P&gt;Microsoft Customer Service and Support (CSS) North America&lt;/P&gt;
&lt;P&gt;These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9828963" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/nav_developer/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/nav_developer/archive/tags/NAV+2009/default.aspx">NAV 2009</category><category domain="http://blogs.msdn.com/nav_developer/archive/tags/Web+Services/default.aspx">Web Services</category></item><item><title>Customizing style sheets for MS Excel </title><link>http://blogs.msdn.com/nav_developer/archive/2009/02/18/customizing-style-sheets-for-ms-excel.aspx</link><pubDate>Wed, 18 Feb 2009 12:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9430791</guid><dc:creator>jvukovic</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/nav_developer/comments/9430791.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nav_developer/commentrss.aspx?PostID=9430791</wfw:commentRss><description>&lt;P&gt;As of version 5.0, Dynamics NAV introduced the option to export forms to MS Office (Word or Excel). Data presented on the form are exported in an xml, formatted using style sheets then sent to Word/Excel/Other programs&lt;/P&gt;
&lt;P&gt;A Style Sheet tool for Dynamics NAV has later been released&amp;nbsp;to help partners create custom style sheets for export to Word in an easy and user friendly way. A possibillity for extending functionality to export to Excel&amp;nbsp;might be&amp;nbsp;considered&amp;nbsp;for future versions.&lt;/P&gt;
&lt;P&gt;Meanwhile, customizing style sheets for excel, though requireing basic knowledge in xml&amp;nbsp;and style sheets, can be simplified with some coding handling basic formatting&amp;nbsp;of style sheets.&lt;/P&gt;
&lt;P&gt;The FOB attached contains an example of how to create such a tool,&amp;nbsp;allowing some&amp;nbsp;basic customizations to excel style sheets. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Style Tool for Excel (xlt)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The Style Toos for EXceL (xlt) is designed to make it easier to customize style sheets for exporting to Excel. Style sheets have endless possibilities to format your Excel documents. This tool makes some of the most common possibilities simpler, but does not cover all possible changes, so it may not eliminate the need for editing style sheets in external tools, but may help you with some simple customizations.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Note, this tool was created&amp;nbsp;and tested on &amp;nbsp;5.01 update 1 client, and assumes using default NavisionFormToExcel style sheet (update 1) as&amp;nbsp;a starting point&amp;nbsp;for customizations.&lt;/P&gt;
&lt;P mce_keep="true"&gt;To use it with 5.0 client, you might need to modify the tool.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;&lt;STRONG&gt;This is what you can achieve with xlt:&lt;/STRONG&gt;&lt;BR&gt;Define a (font) style to be used on document, for example Bold, color, underline, itallic, etc.&lt;BR&gt;Define a style for certain condition, for example "Net Change" &amp;lt; 0, "Customer No." = 10000, etc&lt;BR&gt;Add totals.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;&lt;STRONG&gt;How to use xlt:&lt;/STRONG&gt;&lt;BR&gt;All functionality in the tool can be accessed from form 73000 "XLT Style Card". Run the form and insert a new record to create a new custom style sheet, and specify Code and Description.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Before you can make changes to a style sheet, you need to import it by clickin on Style -&amp;gt; Import, and choose an existing style sheet for export to Excel (such as NavisionFormToExcel), either from the database or from a file.&lt;/P&gt;
&lt;P mce_keep="true"&gt;On the Destination tab, specify the table and form IDs that the style sheet will be used for.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt; &lt;BR&gt;Run form 73000 and press F3. Fill out Code:ChartOfAccounts, Description: export Chart of Accounts&lt;BR&gt;Import the standard NavisionFormToExcel style sheet (by default placed in &amp;lt;client folder&amp;gt;\Stylehseets), by clicking on Style-Import and selecting NavisionFormToExcel style sheet. &lt;BR&gt;In New XSLT file location field, specify the location of your customized style sheet (example: c:\temp\NewXsltFIleName.xslt).&lt;BR&gt;On Destination tab, specify TableID=15, select 'Style sheet for this form only' and select form 16, Chart of Accounts.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Excel Styles:&lt;BR&gt;&lt;/STRONG&gt;You are now ready to customize your style sheet. To create new style, click Design -&amp;gt; Excel Styles. This shows you the styles that were imported with the standard style sheet. From here you can modify existing, or create new ones. To create a new style, press F3, and enter a Style ID. &lt;BR&gt;Then click on "Edit in Excel (F9)" to define this new style. It will open up Microsoft Excel, and here you can apply any formatting you wish, TO THE TOP LEFT CELL. The style you apply to this cell and it's contents will be imported and applied to all the cells your style applies to. Once you are done applying your style, close and save Excel, and then go back to NAV and confirm to import the style.&lt;/P&gt;
&lt;P mce_keep="true"&gt;As an example, consider the following scenario: we want to modify the existing label (caption) style and also create a new style (red fonts) that we apply to records in Net Change column with negative value.&lt;BR&gt;To modify existing label style, click on Design-Excel Styles, press Page Up/Down to browse between records, find Style ID: Label and Press F9 (Edit in excel). In opened excel ark, go to top left cell, in Excel menu select Home-Font and select a different font (for example, Arial Black, size 14). Change also the color to blue. Close the excel and save the file. In NAV client, click on YEs on prompted question (Please apply format in Excel sheet.....). In the Style tab, check that new style is applied&amp;nbsp; (you should see the record with Option=Font, Property=ss:FontName and Value=Arial Black).&lt;/P&gt;
&lt;P mce_keep="true"&gt;You can apply same kind of change directly in the Style tab (instead of opening Excel), provided you are familiar with properties and values as defined in Excel. If modifying styles directly in Style tab, remember to click 'Update (F11)' to apply changes to style sheet. &lt;/P&gt;
&lt;P mce_keep="true"&gt;Note that &lt;/P&gt;
&lt;P mce_keep="true"&gt;1) moving away from the style by closing the form or moving to the next record will not save any changes you made manually (and not through excel), and &lt;/P&gt;
&lt;P mce_keep="true"&gt;2) the tool does not validate if changes you do manually are valid.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Now we want to create a new style and apply it to Net Change column of records with net change &amp;lt; 0.&lt;BR&gt;Press F3 to create a new style, in Style ID field type RED. Click on F9 (Edit in Excel) and in opened excel sheet click on top left cell. In Excel menu, select Home-Font and select red font color. Close the Style Sheet, answer yes to save changes. In NAV Client answer yes to prompted question (Please apply format in Excel Sheet...). In General tab, You should now see properties defined for StyleID=RED&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;&lt;STRONG&gt;Conditional formatting:&lt;/STRONG&gt;&lt;BR&gt;After designing the style(s), then go back to the XLT Style card, and then click Design -&amp;gt; "Conditional Formatting" to apply this style to certain conditions. It is not recommended that you change any of the existing layouts here, but you can create a new one by clicking "Insert (F3)". This opens a mini-wizard where you can specify which columns and values this will apply to.&lt;/P&gt;
&lt;P mce_keep="true"&gt;To follow our example, we will now specify the condition for using the style created in last step, RED style.&lt;BR&gt;Close the Excel Styles form and in Xslt style card click on Design-Conditional Formatting. Click on F3 (or click on Insert) to create new condition (it is not recommended to modify any of the existnig, defualt ones). Wizard form opens. We will now create a condition to apply style red to NET Change column with values &amp;lt; 0. Select TableID=15 and Field 32 (Net Change). In Condition field, select'&amp;lt;' anad Value=0. Finally, In Choose style select RED. Click on Finish. You should now see your condition defined in General tab. Condition= (@name='Net Change') and (@value&amp;lt;'0').&lt;BR&gt;Click on Update to update the style sheet with new condition.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;&lt;STRONG&gt;Totals&lt;/STRONG&gt;&lt;BR&gt;You can specify fields that you want to create totals for, by clicking on Design -&amp;gt; "Total Fields", and select one or more (numerical!) fields. You also need to add one line of C/AL code in codeunit 403 "Application Launch Management". The following line should be added to Codeunit 403, at the top of function LanuchApp:&lt;BR&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;XLStyleSheetDataMgt.UpdateDataXML(DataXML,StylesheetID);&lt;/P&gt;
&lt;P mce_keep="true"&gt;where XLStyleSheetDataMgt is a new local variable, type Codeunit, subtype 73001 ("XLT Style Sheet Data Mgt")&lt;/P&gt;
&lt;P mce_keep="true"&gt;This will add totals to the data that you export to Excel, and it will add elements to the style sheet to handle these totals. Note: This will not work for RTC because RTC does not make calls to codeunit 403 (see blog here: &lt;A href="http://blogs.msdn.com/nav_developer/archive/2008/12/16/dynamics-nav-2009-and-ms-office-integration-send-to-excel-and-word.aspx" mce_href="http://blogs.msdn.com/nav_developer/archive/2008/12/16/dynamics-nav-2009-and-ms-office-integration-send-to-excel-and-word.aspx"&gt;http://blogs.msdn.com/nav_developer/archive/2008/12/16/dynamics-nav-2009-and-ms-office-integration-send-to-excel-and-word.aspx&lt;/A&gt;).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;&lt;STRONG&gt;Export style sheet:&lt;/STRONG&gt;&lt;BR&gt;When you have created one or more style(s) and applied them to certain conditions, then you generate a new style sheet from the "XLT Style Card"&amp;nbsp; by clicking Style -&amp;gt; Export, and then select to export to file or database. If exporting to database, then a new style sheet will be saved in database, using the Description you have specified in the "XLT Style Card".&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;Open form 18 (Chart of Accounts), in toolbar menu, click on send-to button. Select Microsoft Excel and select 'export Chart of Accounts' style sheet., click on OK.&lt;BR&gt;Chart of Accoutns shoud lbe exported to excelm, with labels in Arial Black font, size 14. Net change column where value &amp;lt; 0 should be marked RED and totals should be present for Net Change column.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Other functionality:&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp; - From "XLT Style Card", tab "Standard Styles", specify a style to apply to totals.&lt;BR&gt;&amp;nbsp; - Click Style -&amp;gt; Reset to re-load the stylesheet, which will erase any changes you have done since you imported it.&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;
&lt;P&gt;These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use. &lt;/P&gt;
&lt;P&gt;All feedback regarding issues or suggestion to this tool are very welcome!&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jasminka Vukovic, Lars Lohndorf-Larsen&lt;/P&gt;
&lt;P&gt;Microsoft Dynamics NO&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Microsoft Customer Service and Support (CSS) EMEA&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9430791" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/nav_developer/attachment/9430791.ashx" length="375260" type="text/plain" /><category domain="http://blogs.msdn.com/nav_developer/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/nav_developer/archive/tags/Style+Sheets/default.aspx">Style Sheets</category><category domain="http://blogs.msdn.com/nav_developer/archive/tags/Excel/default.aspx">Excel</category></item><item><title>Sample of how to read a simple XML document using MSXML DOM in NAV </title><link>http://blogs.msdn.com/nav_developer/archive/2008/03/31/sample-of-how-to-read-a-simple-xml-document-using-msxml-dom-in-nav.aspx</link><pubDate>Mon, 31 Mar 2008 15:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8345521</guid><dc:creator>Lohndorf</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/nav_developer/comments/8345521.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nav_developer/commentrss.aspx?PostID=8345521</wfw:commentRss><description>&lt;P&gt;This is a follow-up to the&amp;nbsp;post "&lt;A class="" href="http://blogs.msdn.com/nav_developer/archive/2008/03/31/sample-of-how-to-create-a-simple-xml-document-using-msxml-dom-in-nav.aspx" target=_blank mce_href="http://blogs.msdn.com/nav_developer/archive/2008/03/31/sample-of-how-to-create-a-simple-xml-document-using-msxml-dom-in-nav.aspx"&gt;how to &lt;STRONG&gt;write&lt;/STRONG&gt; a simple XML document&lt;/A&gt;". The other post conitains a few more background details which I won't repeat here. So even if you only want to &lt;STRONG&gt;read&lt;/STRONG&gt; XML Documents, then you may want to have a look there anyway.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But let's get straight to the point. This is how you can read an XML Document from Microsoft Dynamics NAV, using MSXML DOM:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Create a new codeunit. &lt;/P&gt;
&lt;P&gt;2. Declare&amp;nbsp;these 5 new global variables: &lt;/P&gt;
&lt;P&gt;XMLDoc&amp;nbsp; &amp;nbsp;Type = Automation 'Microsoft XML, v4.0'.DOMDocument &lt;BR&gt;DOMNode&amp;nbsp; &amp;nbsp;Type = Automation 'Microsoft XML, v4.0'.IXMLDOMNode &lt;BR&gt;XMLNodeList&amp;nbsp; &amp;nbsp;Type = Automation 'Microsoft XML, v4.0'.IXMLDOMNodeList&lt;/P&gt;
&lt;P&gt;CurrentElementName&amp;nbsp;&amp;nbsp; Type = Text&amp;nbsp;&amp;nbsp;30&lt;BR&gt;i&amp;nbsp; &amp;nbsp;Type = Integer &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Initialize the Dom Document: &lt;BR&gt;CREATE(XMLDoc); &lt;BR&gt;XMLDoc.async(FALSE); &lt;BR&gt;XMLDoc.load('C:\XML\MyXML.xml'); &lt;/P&gt;
&lt;P&gt;4. Set up a loop to browse through the nodes in the document: &lt;BR&gt;XMLNodeList := XMLDoc.childNodes; &lt;BR&gt;for i := 0 to XMLNodeList.length - 1 do begin &lt;BR&gt;&amp;nbsp; DOMNode := XMLNodeList.item(i); &lt;BR&gt;&amp;nbsp; ReadChildNodes(DOMNode); &lt;BR&gt;end; &lt;/P&gt;
&lt;P&gt;You also have to create ReadChildNodes as a function with one parameter: &lt;BR&gt;CurrentXMLNode, Type = Automation 'Microsoft XML, v4.0'.IXMLDOMNode. &lt;/P&gt;
&lt;P&gt;The reason&amp;nbsp;for the functionis to enable you to run it recursively. This is useful because you don't know how many child nodes there are. And there can easily be a child node inside of another child node.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;So create the function ReadChildNodes.&lt;BR&gt;The function has one parameter: &lt;BR&gt;CurrentXMLNode : Automation "'Microsoft XML, v4.0'.IXMLDOMNode" &lt;/P&gt;
&lt;P&gt;And a number of local variables: &lt;BR&gt;TempXMLNodeList&amp;nbsp;&amp;nbsp; &amp;nbsp;Automation = 'Microsoft XML, v4.0'.IXMLDOMNodeList &lt;BR&gt;TempXMLAttributeList&amp;nbsp;&amp;nbsp; &amp;nbsp;Automation = 'Microsoft XML, v4.0'.IXMLDOMNamedNodeMap &lt;BR&gt;j&amp;nbsp;&amp;nbsp; &amp;nbsp;Integer &lt;BR&gt;k&amp;nbsp;&amp;nbsp;&amp;nbsp;Integer &lt;/P&gt;
&lt;P&gt;The function checks to see what type of node it was called with. A node can be an element, text (data), attribute etc. The node property .nodeType tells you which it is. See the documentation (included in &lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2cf40ae6-368c-4b6b-a185-2dfa92fb7993&amp;amp;DisplayLang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2cf40ae6-368c-4b6b-a185-2dfa92fb7993&amp;amp;DisplayLang=en"&gt;MSXMLSDK&lt;/A&gt;) for a complete list of possible nodeTypes. &lt;/P&gt;
&lt;P&gt;This is the function:&lt;BR&gt;&lt;BR&gt;ReadChildNodes(CurrentXMLNode : Automation "'Microsoft XML, v4.0'.IXMLDOMNode")&lt;BR&gt;CASE FORMAT(CurrentXMLNode.nodeType) OF &lt;/P&gt;
&lt;P&gt;'1': // Element &lt;BR&gt;&amp;nbsp; BEGIN&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Global variable CurrentElementName to keep track of what node&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // we are currently processing&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CurrentElementName := CurrentXMLNode.nodeName;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Process Attributes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // If the element has attributes, then browse through those.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TempXMLAttributeList := CurrentXMLNode.attributes;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR k := 0 TO TempXMLAttributeList.length - 1 DO&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReadChildNodes(TempXMLAttributeList.item(k));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Process Child nodes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TempXMLNodeList := CurrentXMLNode.childNodes;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR j := 0 TO TempXMLNodeList.length - 1 DO&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReadChildNodes(TempXMLNodeList.item(j));&lt;BR&gt;&amp;nbsp; END;&lt;/P&gt;
&lt;P&gt;'2': // Attribute &lt;BR&gt;&amp;nbsp; BEGIN&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MESSAGE(CurrentElementName + ' Attribute : ' +&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT(CurrentXMLNode.nodeName) + ' = ' + FORMAT(CurrentXMLNode.nodeValue));&lt;BR&gt;&amp;nbsp; END;&lt;/P&gt;
&lt;P&gt;'3': // Text &lt;BR&gt;&amp;nbsp; BEGIN&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MESSAGE(CurrentElementName + ' = ' + FORMAT(CurrentXMLNode.nodeValue));&lt;BR&gt;&amp;nbsp; END;&lt;BR&gt;END;&lt;/P&gt;
&lt;P&gt;Now, try to run the codeunit&amp;nbsp;against any XML document, and it will give a MESSAGE for each node and each&amp;nbsp;attribute. This codeunit can be used for scanning any XML document from begin to end.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;U&gt;Next example:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Now, lets say you are looking for specific nodes in an XML document. As an example, take this document:&lt;/P&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Document&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#990000&gt;&lt;SPAN class=t&gt;Order&lt;/SPAN&gt;&lt;SPAN class=t&gt; ID&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;="&lt;/FONT&gt;&lt;/SPAN&gt;&lt;B&gt;1001&lt;/B&gt;&lt;FONT color=#0000ff&gt;&lt;SPAN class=m&gt;"&lt;/SPAN&gt;&lt;SPAN class=m&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=tx&gt;&lt;STRONG&gt;10000 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;70000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;77&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=tx&gt;&lt;STRONG&gt;20000 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;70001&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;99&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Order&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#990000&gt;&lt;SPAN class=t&gt;Order&lt;/SPAN&gt;&lt;SPAN class=t&gt; ID&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;="&lt;/FONT&gt;&lt;/SPAN&gt;&lt;B&gt;1002&lt;/B&gt;&lt;FONT color=#0000ff&gt;&lt;SPAN class=m&gt;"&lt;/SPAN&gt;&lt;SPAN class=m&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=tx&gt;&lt;STRONG&gt;10000 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;70011&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=tx&gt;&lt;STRONG&gt;20000 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;70012&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;45&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/XML/Test.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=tx&gt;&lt;STRONG&gt;30000 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;70014&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;No&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;37&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Amount&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Line&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Order&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;Document&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;One of the good things in MSXML DOM is, that it reads the whole document into memory, so you can jump between nodes, and browse them, and select sub-sets based on node names. So you do not have to read a document from top to bottom if you know exactly which parts of the document you are interested in.&lt;/P&gt;
&lt;P mce_keep="true"&gt;First, we can count how many orders the document contains (see how many "Order"-elements are under the root-element):&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;OnRun()&lt;BR&gt;CREATE(XMLDoc); &lt;BR&gt;XMLDoc.async(FALSE); &lt;BR&gt;XMLDoc.load('C:\XML\Order.xml');&lt;/P&gt;
&lt;P mce_keep="true"&gt;XMLNodeList := XMLDoc.getElementsByTagName('Document/Order');&lt;BR&gt;MESSAGE('The document has %1 elements called Order',XMLNodeList.length);&lt;/P&gt;
&lt;P mce_keep="true"&gt;This will open the XML document, then use the getElementsByTagName-function to get all elements that match the tag name. Note that the tag name you specify is case sensitive (like everything else in XML)! So in this case, it would not find elements called "order".&lt;/P&gt;
&lt;P mce_keep="true"&gt;Once you have the XMLNodeList, then you can go through the nodes in that list, using the first example.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Finally, an example which will read the XML document shown above, and show an Amount-total for each order:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;OnRun()&lt;BR&gt;CREATE(XMLDoc); &lt;BR&gt;XMLDoc.async(FALSE); &lt;BR&gt;XMLDoc.load('C:\XML\Order.xml');&lt;/P&gt;
&lt;P mce_keep="true"&gt;XMLNodeList := XMLDoc.getElementsByTagName('Document/Order');&lt;BR&gt;FOR i := 0 TO XMLNodeList.length - 1 DO BEGIN&lt;BR&gt;&amp;nbsp; NumberDecTotal := 0;&lt;BR&gt;&amp;nbsp; DOMNode := XMLNodeList.item(i);&lt;BR&gt;&amp;nbsp; XMLNodeList2 := DOMNode.selectNodes('Line/Amount');&lt;BR&gt;&amp;nbsp; FOR j := 0 TO XMLNodeList2.length - 1 DO BEGIN&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DOMNode2 := XMLNodeList2.item(j);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NumberAsText := FORMAT(DOMNode2.text);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EVALUATE(NumberDec,NumberAsText);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NumberDecTotal := NumberDecTotal + NumberDec;&lt;BR&gt;&amp;nbsp; END;&lt;BR&gt;&amp;nbsp; MESSAGE('Order has total amount of %1.',NumberDecTotal);&lt;BR&gt;END;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;This example uses DomNode.SelectNodes, which will select all matching nodes. If you are looking for an individual node, then you can use DomNode.selectSingleNode which will only return one node (the first that matches).&lt;/P&gt;
&lt;P mce_keep="true"&gt;In an XML document, everything is Text. So you have to convert to numbers where needed. Final note: Make sure to make your code more robust than this! What if Amount contains a character? What if an element is missing? If you don't take these things into consideration, then your code can fail with very&amp;nbsp;unfriendly errors.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;Best regards 
&lt;P&gt;&lt;BR&gt;Lars Lohndorf-Larsen&lt;/P&gt;
&lt;P&gt;Microsoft Dynamics UK&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Microsoft Customer Service and Support (CSS) EMEA&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8345521" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/nav_developer/archive/tags/XML/default.aspx">XML</category></item><item><title>Sample of how to write a simple XML document using MSXML DOM in NAV</title><link>http://blogs.msdn.com/nav_developer/archive/2008/03/31/sample-of-how-to-create-a-simple-xml-document-using-msxml-dom-in-nav.aspx</link><pubDate>Mon, 31 Mar 2008 14:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8345520</guid><dc:creator>Lohndorf</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/nav_developer/comments/8345520.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nav_developer/commentrss.aspx?PostID=8345520</wfw:commentRss><description>&lt;P&gt;This post if for when you&amp;nbsp;need to export data in the form of XML from Microsoft Dynamics NAV. If you are not familiar with how to program with MSXML DOM, then it can take a lot of time and work to create even a simple XML document. The purpose of this post is to show a simple example, and to get you started programming with MSXML DOM from NAV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I have split this into two posts: "How to write" (this post), and "How to read" an XML Document (&lt;A class="" href="http://blogs.msdn.com/nav_developer/archive/2008/03/31/sample-of-how-to-read-a-simple-xml-document-using-msxml-dom-in-nav.aspx" target=_blank mce_href="http://blogs.msdn.com/nav_developer/archive/2008/03/31/sample-of-how-to-read-a-simple-xml-document-using-msxml-dom-in-nav.aspx"&gt;click here&lt;/A&gt;), since the methods and functions used are quite different.&lt;/P&gt;
&lt;P&gt;Why not just use XML-Ports? You can of course, but then you limit yourself to the functionality and limitations that exist in XML-Ports. An example of a limitation in XML-Ports is that they do not support namespaces. If you think that one day you may need functionality that is not supported by XML-Ports, and for which you have to use MSXML DOM anyway, then consider to just use MXSML DOM from the start. It is more complex to begin with, but once you have a set of functions to add / search etc elements in an XML document, then it does not have to be much more complex than using XML-Ports. Note that it is &lt;STRONG&gt;not&lt;/STRONG&gt; possible to access an XML docuemnt via MSXML DOM from an XML-Port while the XML-Port is accessing it. The two methods are mutually exclusive.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;An XML document is organized as a heararchy of elements, and everything (elements and data) gets added piece by piece to existing elements. &lt;/P&gt;
&lt;P&gt;Let's get started with the simplest possible XML DOcument:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Create a new codeunit with 3 variables:&lt;BR&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataType&amp;nbsp;Subtype&amp;nbsp;Length&lt;BR&gt;XMLDoc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automation&amp;nbsp;'Microsoft XML, v4.0'.DOMDocument&amp;nbsp;&lt;BR&gt;DOMNode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automation&amp;nbsp;'Microsoft XML, v4.0'.IXMLDOMNode&amp;nbsp;&lt;BR&gt;DomTextNode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automation&amp;nbsp;'Microsoft XML, v4.0'.IXMLDOMText&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example I use MSXML version 4, but you can use version 5 or 6 if you prefer. Version 4 is mostly used because it most likely contains all the functionality you will need, and it will be backward compatible to more machines - even old ones.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Initialize the document:&lt;/P&gt;
&lt;P&gt;OnRun()&lt;BR&gt;CREATE(XMLDoc);&lt;BR&gt;XMLDoc.async(FALSE);&lt;/P&gt;
&lt;P&gt;Unless you have specific reasons not to, set asynch = FALSE. Especially when you are reading an XML document. It means that it will load the whole document into memory before it starts reading through it. If you don't set this property, you may begin to process the document before it is completely loaded into memory.&lt;/P&gt;
&lt;P&gt;Now create a new node, and then add it to the document:&lt;/P&gt;
&lt;P&gt;DOMNode := XMLDoc.createNode(1,'NodeName',''); &lt;BR&gt;XMLDoc.appendChild(DOMNode); &lt;/P&gt;
&lt;P&gt;Then add some data. This is done in the same way as you add an element: Creat the element first, and then add it to the right place in the document:&lt;/P&gt;
&lt;P&gt;DOMTextNode := XMLDoc.createTextNode('NodeValue'); &lt;BR&gt;DOMNode.appendChild(DOMTextNode); &lt;/P&gt;
&lt;P&gt;You can add any additional elements like this: Creat&amp;nbsp;the element of the type that you need (node, text, attribute etc), and then append it to the&amp;nbsp;document.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;To see the document, save it to disk:&lt;BR&gt;XMLDoc.save('C:\XML\MyXML.xml'); &lt;/P&gt;
&lt;P&gt;Note: If you run on Vista, it might not allow you to save files on the root of the c: drive. So create a new folder, for example c:\XML\&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Then run this codeunit. You should get a very simple document like this:&lt;BR&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;NodeName&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;NodeValue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;NodeName&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;If you want to add further nodes to this document then&amp;nbsp;repeat the steps above to create a new node, then append it to an existing node. For example, to add a new node:&lt;/P&gt;
&lt;P&gt;Create a new variable: &lt;BR&gt;NewDOMNode : 'Microsoft XML, v4.0'.IXMLDOMNode &lt;/P&gt;
&lt;P&gt;Initialize the new node: &lt;BR&gt;NewDOMNode := XMLDoc.createNode(1,'NewNode',''); &lt;BR&gt;DOMNode.appendChild(NewDOMNode); &lt;/P&gt;
&lt;P&gt;And add text to the new node: &lt;BR&gt;DOMTextNode := XMLDoc.createTextNode('NewNodeValue'); &lt;BR&gt;NewDOMNode.appendChild(DOMTextNode); &lt;/P&gt;
&lt;P&gt;Now, your xml document will look like this: &lt;/P&gt;
&lt;DIV class=e&gt;
&lt;DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;A class=b onfocus=h() onclick="return false" href="file:///C:/x/MyXML.xml#"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;NodeName&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class=e&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=tx&gt;&lt;STRONG&gt;NodeValue&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;DIV class=e&gt;
&lt;DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;NewNode&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=tx&gt;&lt;STRONG&gt;NewNodeValue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;NewNode&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=b&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#ff0000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=t&gt;&lt;FONT color=#990000&gt;NodeName&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=m&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding namespace and Attributes: &lt;/P&gt;
&lt;P&gt;You can add a name space either to the whole document, or to individual nodes. To add a name space to the document, go back to the relevant line above, and specify the 3rd parameter: &lt;/P&gt;
&lt;P&gt;DOMNode := XMLDoc.createNode(1,'NodeName','MyNameSpace'); &lt;/P&gt;
&lt;P&gt;Finally, adding an attribute to a node is similar to adding a text element: Initialize the Attribute, then add it to the relevant node. Use the function SetNamedItem to add attributes. Let's add an attribute called ID with the value 10000: &lt;/P&gt;
&lt;P&gt;Create a new Automation variable: &lt;BR&gt;XMLAttributeNode : 'Microsoft XML, v5.0'.IXMLDOMAttribute &lt;/P&gt;
&lt;P&gt;Initialize the attribute, then add it to the node: &lt;BR&gt;XMLAttributeNode := XMLDoc.createAttribute('ID'); &lt;BR&gt;XMLAttributeNode.value := '10000'; &lt;BR&gt;DOMNode.attributes.setNamedItem(XMLAttributeNode); &lt;/P&gt;
&lt;P&gt;The whole codeunit should now look like this: &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;// Initialize the document &lt;BR&gt;CREATE(XMLDoc); &lt;BR&gt;// Create Node and attach it to the document. Use name space MyNameSpacefunction &lt;BR&gt;DOMNode := XMLDoc.createNode(1,'NodeName','MyNameSpace'); &lt;BR&gt;XMLDoc.appendChild(DOMNode); &lt;/P&gt;
&lt;P&gt;// Add data (text) to the node &lt;BR&gt;DOMTextNode := XMLDoc.createTextNode('NodeValue'); &lt;BR&gt;DOMNode.appendChild(DOMTextNode); &lt;/P&gt;
&lt;P&gt;// Add an attribute to the node &lt;BR&gt;XMLAttributeNode := XMLDoc.createAttribute('ID'); &lt;BR&gt;XMLAttributeNode.value := '10000'; &lt;BR&gt;DOMNode.attributes.setNamedItem(XMLAttributeNode); &lt;/P&gt;
&lt;P&gt;// Initialize a new node: &lt;BR&gt;NewDOMNode := XMLDoc.createNode(1,'NewNode',''); &lt;BR&gt;DOMNode.appendChild(NewDOMNode); &lt;/P&gt;
&lt;P&gt;// And add text to the new node: &lt;BR&gt;DOMTextNode := XMLDoc.createTextNode('NewNodeValue'); &lt;BR&gt;NewDOMNode.appendChild(DOMTextNode); &lt;/P&gt;
&lt;P&gt;// Finally, save the document for viewing: &lt;BR&gt;XMLDoc.save('C:\XML\MyXML.xml'); &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Further references:&lt;/P&gt;
&lt;P&gt;MSXML is further documented in &lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2cf40ae6-368c-4b6b-a185-2dfa92fb7993&amp;amp;DisplayLang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2cf40ae6-368c-4b6b-a185-2dfa92fb7993&amp;amp;DisplayLang=en"&gt;MSXML Software Development Kit (MSXMLSDK)&lt;/A&gt;. I would recommend that you download this to have the online help available for all of the MSXML DOM functions.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;These postings are provided "AS IS" with no warranties and confer no rights.&lt;BR&gt;You assume all risk for your use.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lars Lohndorf-Larsen&lt;/P&gt;
&lt;P&gt;Microsoft Dynamics UK&lt;BR&gt;Microsoft Customer Service and Support (CSS) EMEA&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8345520" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/nav_developer/archive/tags/XML/default.aspx">XML</category></item></channel></rss>