GETTING ERROR for the below macro script. Need extract date, name and address in a single table. Since there is only one value of date, the second value returns null.
However I need the same value to be present in all records of extract date
Set ApplicationsNode = oXMLFile.SelectNodes("/Extract/Applications/Application")
Set extractnodes = oXMLFile.SelectNodes("/Extract/ExtractDate")
Set NameNode = oXMLFile.SelectNodes("/Extract/Applications/Application/Name/text()")
Set AddrNode = oXMLFile.SelectNodes("/Extract/Applications/Application/Addr/text()")
For i = 0 To (ApplicationsNode.Length - 1)
Extract = extractnodes(i).NodeValue
Name = NameNode(i).NodeValue
Addr = AddrNode(i).NodeValue
mainWorkBook.Sheets("Sheet1").Range("A" & i + 2).Value = Extract
mainWorkBook.Sheets("Sheet1").Range("C" & i + 2).Value = Name
mainWorkBook.Sheets("Sheet1").Range("D" & i + 2).Value = Addr
Next
Input XML:
<Extract>
<ExtractDate>2018-02-21 10:01:01</ExtractDate>
<Applications>
<Application>
<Name>1234</Name>
<Addr>700ST</Addr>
</Application>
<Application>
<Name>123466</Name>
<Addr>277AVD</Addr>
</Application>
<Applications>
</Extract>
Try using the below portion of elements within
content.xmlfile in desktop and run the below code.within
content.xmlfile:Script to parse the value from:
Populated results: