XML get elements with same name

helder
Member Posts: 2
In CAL NAV2013, I want to get all elements with the same name (in this case codMsg and txtMsg). At the moment I'm trying only with the codMsg.
Example XML nodes:
I have tried:
1) itemsAlert.Item(i).SelectSingleNode('codMsg'), this way I only have the first element (codMsg) of each alert node.
2)
How to access to: ae12; ae13; ae14...
With this "itemsAlertNode := itemsAlert.Item(i).SelectNodes('codMsg');" I see a System.XML.XPathNodeList, but I don't know if the content is what I want. Is there some way to view the content by debugging?
This is the first time I'm programming...
Thanks
Example XML nodes:
<alerta> <actCount> <num>0001</num> <tipo>3</tipo> </actCount> <codMsg>ae11</codMsg> <txtMsg>description11</txtMsg> <codMsg>ae12</codMsg> <txtMsg>description12</txtMsg> <codMsg>ae13</codMsg> <txtMsg>description13</txtMsg> <codMsg>ae14</codMsg> <txtMsg>description14</txtMsg> </alerta> <alerta> <actCount> <num>0002</num> <tipo>3</tipo> </actCount> <codMsg>ae21</codMsg> <txtMsg>description21</txtMsg> <codMsg>ae22</codMsg> <txtMsg>description22</txtMsg> <codMsg>ae23</codMsg> <txtMsg>description3</txtMsg> <codMsg>ae24</codMsg> <txtMsg>description24</txtMsg> </alerta>
I have tried:
1) itemsAlert.Item(i).SelectSingleNode('codMsg'), this way I only have the first element (codMsg) of each alert node.
2)
itemsAlertNode := itemsAlert.Item(i).SelectNodes('codMsg'); IF itemsAlertNode.Count > 0 THEN BEGIN FOR j := 0 TO itemsAlertNode.Count - 1 DO BEGIN //title_codMsg := itemsAlertNode.Item(j).SelectSingleNode('/'); - no error, but doesn't get the content of element //title_codMsg := itemsAlertNode.Item(j).SelectSingleNode('codMsg'); - error at: title_codMsgTxt := title_codMsg.InnerText, because title_codMsg is uninitialized //title_codMsg := itemsAlertNode.Item(j).SelectSingleNode(''); - Expression must evaluate to a node-list title_codMsgTxt := title_codMsg.InnerText; END; END;
How to access to: ae12; ae13; ae14...
With this "itemsAlertNode := itemsAlert.Item(i).SelectNodes('codMsg');" I see a System.XML.XPathNodeList, but I don't know if the content is what I want. Is there some way to view the content by debugging?
This is the first time I'm programming...
Thanks

0
Answers
-
I found the error....
The solution is use only: title_codMsg := itemsAlertNode.Item(j);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