Selecting Elements

PhoenixCNC
Member Posts: 12
Within this XML file i need to store the first 3 elements within a temp table. After selecting the node path how can I essentially skip onto the next node? Or only select the 3 from the header to apply to the body.
In this instance I have I want to store the 'Location, Component and Comment' within the thead.
xmlNodeListDataHeader := xmlDoc.SelectNodes('hr/table/thead/tr/th');
So when looping through the tbody I only want to store the lines highlighted and skip the rest. How can this be done?
xmlNodeListDataHeader := xmlDoc.SelectNodes('hr/table/thead/tr/th');
xmlNodeListData := xmlDoc.SelectNodes('hr/table/tbody/tr/td');
FOR intNodeHeader := 0 TO xmlNodeListDataHeader.Count-1 DO BEGIN
xmlNodeHeader := xmlNodeListDataHeader.Item(intNodeHeader)
END;
FOR intNode := 0 TO xmlNodeListData.Count-1 DO BEGIN
xmlNode := xmlNodeListData.Item(intNode);
MESSAGE('%1', xmlNode.InnerText);
// Store the items in a temp table
END;

In this instance I have I want to store the 'Location, Component and Comment' within the thead.
xmlNodeListDataHeader := xmlDoc.SelectNodes('hr/table/thead/tr/th');
So when looping through the tbody I only want to store the lines highlighted and skip the rest. How can this be done?
xmlNodeListDataHeader := xmlDoc.SelectNodes('hr/table/thead/tr/th');
xmlNodeListData := xmlDoc.SelectNodes('hr/table/tbody/tr/td');
FOR intNodeHeader := 0 TO xmlNodeListDataHeader.Count-1 DO BEGIN
xmlNodeHeader := xmlNodeListDataHeader.Item(intNodeHeader)
END;
FOR intNode := 0 TO xmlNodeListData.Count-1 DO BEGIN
xmlNode := xmlNodeListData.Item(intNode);
MESSAGE('%1', xmlNode.InnerText);
// Store the items in a temp table
END;

0
Best Answer
-
Resolved
xmlDoc := xmlDoc.XmlDocument();
xmlDoc.Load('\\tioga-eng\Shared\NavData_Public\Testing\' + cuCPUtils.UserBatch() + 'BOT2.xml');
IF FindNode(xmlDoc, '//table/tbody', XMLNode) THEN BEGIN
// Get all <tr> nodes
XMLNodeList := XMLNode.SelectNodes('tr');
Nodes := XMLNodeList.Count;
FOR intNode := 0 TO Nodes -1 DO BEGIN
XMLNode2 := XMLNodeList.ItemOf(intNode);
// All <td> nodes inside the <tr> node
XMLNodeList2 := XMLNode2.SelectNodes('td');
Nodes2 := XMLNodeList2.Count;
FOR intNode2 := 0 TO Nodes2 -1 DO BEGIN
XMLNode3 := XMLNodeList2.ItemOf(intNode2);
IF intNode2 IN [0,1,2] THEN BEGIN
IF NOT ISNULL(XMLNode3) THEN
Values[intNode2+1] := XMLNode3.InnerText
ELSE
Values[intNode2+1] := '';
END;
END;
END;
END;0
Answers
-
Resolved
xmlDoc := xmlDoc.XmlDocument();
xmlDoc.Load('\\tioga-eng\Shared\NavData_Public\Testing\' + cuCPUtils.UserBatch() + 'BOT2.xml');
IF FindNode(xmlDoc, '//table/tbody', XMLNode) THEN BEGIN
// Get all <tr> nodes
XMLNodeList := XMLNode.SelectNodes('tr');
Nodes := XMLNodeList.Count;
FOR intNode := 0 TO Nodes -1 DO BEGIN
XMLNode2 := XMLNodeList.ItemOf(intNode);
// All <td> nodes inside the <tr> node
XMLNodeList2 := XMLNode2.SelectNodes('td');
Nodes2 := XMLNodeList2.Count;
FOR intNode2 := 0 TO Nodes2 -1 DO BEGIN
XMLNode3 := XMLNodeList2.ItemOf(intNode2);
IF intNode2 IN [0,1,2] THEN BEGIN
IF NOT ISNULL(XMLNode3) THEN
Values[intNode2+1] := XMLNode3.InnerText
ELSE
Values[intNode2+1] := '';
END;
END;
END;
END;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