0
votes

I have a XML file in the below format..What I am doing here is going through the files in the common node and looping through them ..The issue is the comments inside the common node throws an error which says the getAttribute("name") is not supported ..Can someone please tell me how to loop through child nodes and avoid reading the commented lines.

Set objNodeList = xmlDoc.getElementsByTagName("Common")

For each comNodeItem in objNodeList

   On Error Resume Next
    for each fileNodeItem in comNodeItem.ChildNodes        

        fileName = fileNodeItem.getAttribute("name")   



  next

    <Common>
        <!-- Test Comment -->
        <file name="Test1.css"/>
            <file name="Test2.css"/>
    </Common>
    <Common>
        <!-- Test Comment -->
        <file name="Test3.css"/>
            <file name="Test4.css"/>
    </Common>
1
Please describe the actual problem you're trying to solve instead of what you perceive as the solution. Why do you believe you need to process the child nodes grouped by parent node? - Ansgar Wiechers

1 Answers

0
votes

You may consider trying the following code snippet.

Set xmlDoc = CreateObject("MSXML.DomDocument")
xmlDoc.LoadXML "<Common><!-- Test Comment --><file name='Test1.css'/><file name='Test2.css'/></Common>"
For Each xmlFile in xmlDoc.selectNodes("//file")
    MsgBox xmlFile.getAttribute("name")
Next