I've modified your code to match my xml data, but when I run the code, it highlights yellow the first item in the loop. How does it know to look for my specific child nodes? My xml is much larger and has many tables associated with it, but I only need the data from one particular section.
It sounds like the code is highlighting because it's trying to loop through all child nodes, but it needs to be more specific for your larger XML. To focus on one section, you'll want to target the exact node you're interested in. Here's an example: Dim xmlDoc As Object Set xmlDoc = CreateObject("MSXML2.DOMDocument") xmlDoc.Load (filePath) ' Adjust "SectionName" to match the part of your XML you need Dim sectionNode As Object Set sectionNode = xmlDoc.SelectSingleNode("//SectionName") If Not sectionNode Is Nothing Then Dim childNode As Object For Each childNode In sectionNode.ChildNodes Debug.Print childNode.Text Next childNode Else MsgBox "Section not found" End If Make sure to check your XML structure to find the right node. If your XML is more complex, adjust the SelectSingleNode with the correct path.
@@Mindful_Explorer Thanks! Still can't get the code to parse the data. my xml has much more data. It's a series of tables that include stuff like: . So trying to mirror yours is very confusing for me lol
Huge thanks to you! It was very useful for me. I have understood how to create XML parser i need!
I've modified your code to match my xml data, but when I run the code, it highlights yellow the first item in the loop. How does it know to look for my specific child nodes? My xml is much larger and has many tables associated with it, but I only need the data from one particular section.
It sounds like the code is highlighting because it's trying to loop through all child nodes, but it needs to be more specific for your larger XML. To focus on one section, you'll want to target the exact node you're interested in. Here's an example:
Dim xmlDoc As Object
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.Load (filePath)
' Adjust "SectionName" to match the part of your XML you need
Dim sectionNode As Object
Set sectionNode = xmlDoc.SelectSingleNode("//SectionName")
If Not sectionNode Is Nothing Then
Dim childNode As Object
For Each childNode In sectionNode.ChildNodes
Debug.Print childNode.Text
Next childNode
Else
MsgBox "Section not found"
End If
Make sure to check your XML structure to find the right node. If your XML is more complex, adjust the SelectSingleNode with the correct path.
@@Mindful_Explorer Thanks! Still can't get the code to parse the data. my xml has much more data. It's a series of tables that include stuff like: . So trying to mirror yours is very confusing for me lol
please share me XML file in the video