title: How to get child nodes from XML using vbscript
body: <p>I have the following type XML file:</p>
  
  <pre><code>&lt;ECSC&gt;
     &lt;ATTRIBUTES&gt;
          &lt; all child nodes of attribute tag &gt;
     &lt;/ATTRIBUTES&gt;
     &lt;SCRIPT&gt;
        &lt;ETXML_LINE_TABTYPE&gt;
            &lt;item&gt;MESSAGE ( MSG_1 ).&lt;/item&gt;
      &lt;item&gt;* To get the name of the Title Screen.&lt;/item&gt;
      &lt;item&gt;  GETGUI ( FB01_100_STEP_1 ).&lt;/item&gt;
  
      &lt;item&gt;  SAPGUI ( FB01_100_STEP_2 ).&lt;/item&gt;
      &lt;item&gt;* Enter Amount and Tax Code.&lt;/item&gt;
      &lt;item&gt;* and, Press F4 help in the Order Field.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_300_STEP_1 ).&lt;/item&gt;
      &lt;item&gt;* In F4 screen, enter the 'External Order Number'&lt;/item&gt;
      &lt;item&gt;* pop-up screen is displayed with entries like Order, Description and External Order Number and select 1st order row, press Enter.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_200_STEP_1 ).&lt;/item&gt;
      &lt;item&gt;* To get the values for the field 'Order, Description and External Order No' from F4 help.&lt;/item&gt;
      &lt;item&gt;  GETGUI ( FB01_120_STEP_1 ).&lt;/item&gt;
      &lt;item&gt;* Press 'Enter' button.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_120_STEP_3 ).&lt;/item&gt;
      &lt;item&gt;* To get the value for the field 'Order' from Main screen.&lt;/item&gt;
      &lt;item&gt;  GETGUI ( FB01_300_STEP_2 ).&lt;/item&gt;
      &lt;item&gt;* click on 'F3' back button.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_300_STEP_3 ).&lt;/item&gt;
      &lt;item&gt;* click on 'F3' back button.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_700_STEP_1 ).&lt;/item&gt;
      &lt;item&gt;* click 'Yes' button.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_200_STEP_2 ).&lt;/item&gt;
      &lt;item&gt;* click on 'F3' back button.&lt;/item&gt;
      &lt;item&gt;  SAPGUI ( FB01_100_STEP_3 ).&lt;/item&gt;
      &lt;item&gt;ENDMESSAGE ( E_MSG_1 ).&lt;/item&gt;
      &lt;item/&gt;
      &lt;item&gt;* To display the Title Screen.&lt;/item&gt;
      &lt;item&gt;  LOG ( V_TITLE_SCREEN ).&lt;/item&gt;
      &lt;item&gt;* To display the 'Order' Number from F4 help.&lt;/item&gt;
      &lt;item&gt;  LOG ( V_ORDER_NO_FROM_F4 ).&lt;/item&gt;
      &lt;item&gt;* To display the 'Description' from F4 help.&lt;/item&gt;
      &lt;item&gt;  LOG ( V_DESCRIPTION_FROM_F4).&lt;/item&gt;
      &lt;item&gt;* To display the 'External Order no' value from F4 help.&lt;/item&gt;
      &lt;item&gt;  LOG ( V_EXTERNAL_ORDER_NO_FROM_F4 ).&lt;/item&gt;
      &lt;item&gt;* To display the 'Order' Number from main screen.&lt;/item&gt;
      &lt;item&gt;  LOG ( V_ORDER_NO_FRM_MAIN_SCREEN ).&lt;/item&gt;
      &lt;item&gt;*********************************************************************.&lt;/item&gt;
      &lt;item&gt;* End Execution.&lt;/item&gt;
      &lt;item&gt;*********************************************************************.&lt;/item&gt;
      &lt;item/&gt;
      &lt;item&gt;*******************************************************************.&lt;/item&gt;
      &lt;item&gt;* Check.&lt;/item&gt;
      &lt;item&gt;********************************************************************.&lt;/item&gt;
      &lt;item&gt;* To check name of Title screen for transaction FB01.&lt;/item&gt;
      &lt;item&gt;  CHEVAR ( V_TITLE_SCREEN = I_TITLE_SCREEN ).&lt;/item&gt;
      &lt;item&gt;* To check the value for the field 'External Order No' from F4 help, which should be equal to 'External Order No' from table.&lt;/item&gt;
      &lt;item&gt;  CHEVAR ( V_EXTERNAL_ORDER_NO_FRM_TABL = V_EXTERNAL_ORDER_NO_FROM_F4 ).&lt;/item&gt;
      &lt;item&gt;* To check the values for the field 'Order' number from Table, which should be equal to 'Order' no from F4 screen and Main screen.&lt;/item&gt;
      &lt;item&gt;  CHEVAR ( ( I_ORDER_NUMBER_FROM_TABLE = V_ORDER_NO_FROM_F4 ) AND ( I_ORDER_NUMBER_FROM_TABLE = V_ORDER_NO_FRM_MAIN_SCREEN )).&lt;/item&gt;
      &lt;item&gt;*******************************************************************.&lt;/item&gt;
      &lt;item&gt;* End Check.&lt;/item&gt;
      &lt;item&gt;********************************************************************.&lt;/item&gt;
      &lt;/ETXML_LINE_TABTYPE&gt;
     &lt;/SCRIPT&gt;
    &lt;PARAMETERS&gt;
          &lt;all childnodes of parameter of parameters tag &gt;
    &lt;/PARAMETERS&gt;
    &lt;/ECSC&gt;
  </code></pre>
  
  <p>We want to select a particular node like <code>&lt;SCRIPT&gt;</code> and its all child nodes like all <code>&lt;item&gt;</code> nodes from above XML; we want to detect such nodeText having doesn't have any comment mentioned. Comment is denoted by line which is starting from character <code>*</code> and each comment line is present just above the code line; for example in above XML file, the line: <code>&lt;item&gt;  SAPGUI ( FB01_100_STEP_2 ).&lt;/item&gt;</code> doesn't have any comment so it is a defect, and I tried the following vbscript.</p>
  
  <pre><code>Dim sFSpec   : sFSpec       = "D:\new Automation\backup\script.xml"
  Dim objMSXML : Set objMSXML = CreateObject("Msxml2.DOMDocument")
  objMSXML.setProperty "SelectionLanguage", "XPath"
  objMSXML.async = False
  objMSXML.load sFSpec
  If 0 = objMSXML.parseError Then
   Dim bCmnt : bCmnt = False
   Dim ndItem
   For Each ndItem In objMSXML.documentElement.childNodes
       Dim sItem : sItem = ndItem.text
       If "*" = Left(sItem, 1) Then
          bCmnt = True
       Else
          If Not bCmnt Then
            If "" &lt;&gt; sItem And 0 = Instr(sItem, "MESSAGE") Then
               msgbox "no comment for:", sItem
             End If
          End If
          bCmnt = False
       End If
   Next
  Else
     msgbox objMSXML.parseError.reason
  End If
  </code></pre>
  
  <p>Please help me. Thank You in advance.</p>