Click here to Skip to main content
15,888,073 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have the sample XML, where I need to write the "DELAY" details under. Schedule table>Lin schedule table>table entrys for each "LIN-CLUSTER" respectively to excel.

I have tried the code, but it is writing all the schedule table details irrespective of cluster name. Please help how to write according to each cluster in each loop

Please ignore the indentations. I am using in mobile.

Sample XML
XML
<lin-cluster>
  <short-name>LIN4
  <lin-cluster-variants>
    <lin-cluster-conditional>
       <baudrate>19200
       <physical-channels>
          <lin-physical-channel>
              <short-name>ML4       
              <schedule-tables>
                 <lin-schedule-table>
                    <short-name>RUN                
                   <table-entrys>
                      <application -="" entrys="">
                         <delay>0.01
                     
                  
                <lin-schedule-table>
             
         
       
     
   


 
<lin-cluster>
  <short-name>LIN4
  <lin-cluster-variants>
    <lin-cluster-conditional>
       <baudrate>19200
       <physical-channels>
          <lin-physical-channel>
              <short-name>ML4       
              <schedule-tables>
                 <lin-schedule-table>
                    <short-name>RUN                
                   <table-entrys>
                      <application -="" entrys="">
                         <delay>0.01
                     
                  
                <lin-schedule-table>
             
         
       
     
   


<lin-cluster>
  <short-name>LIN4
  <lin-cluster-variants>
    <lin-cluster-conditional>
       <baudrate>19200
       <physical-channels>
          <lin-physical-channel>
              <short-name>ML4       
              <schedule-tables>
                 <lin-schedule-table>
                    <short-name>RUN                
                   <table-entrys>
                      <application -="" entrys="">
                         <delay>0.01
                     
                  
                <lin-schedule-table>


What I have tried:

VB
Dim OXMLDOC As Object= Nothing
oXMLDOC = CreateObject. 
                                  ("Microsoft.XMLDOM")
OXMLDOC.Load("sample.xml")

nodes1=OXMLDOC.SelectNodes("//LIN- 
                                                   CLUSTER")
For each node1 in nodes1
   For each node2 in node1.ChildNodes
       If node2.tagName="SHORT-NAME" 
                                                                  Then
            xlSH.Cells(iRow,1) =node2.Text
      ElseIf node2.tagName="LIN-CLUSTER- 
                                             VARIANTS" Then
            nodes3=node2.SelectNodes("//LIN-CLUSTER-VARIANTS/LIN-CLUSTER-CONDITIONAL/PHYSICAL-CHANNELS/LIN-PHYSICAL-CHANNEL/SCHEDULE-TABLES/LIN-SCHEDULE-TABLE/*")
           For each node3 in nodes3 
               If node3.tagName="SHORT- 
                                                             NAME"
                    xlSH.Cells(iRow,4)=node3.text
               ElseIf node3.tagName="TABLE- 
                                                        ENTRYS"           
                    nodes4=node3.SelectNode("(APPLICATION-ENTRY|ASSIGN-FRAME-ID|ASSIGN-FRAME-ID-RANGE)/*)
                    For each node4 in nodes4
                        If node4.tagName="DELAY" 
                                                             Then                  
                             xlSH.Cells(iRow,5) = 
                                                        node4.text
                        End If
                    Next
 
              End If
           Next
      End If
   Next
Next
Posted
Updated 17-Feb-20 21:47pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900