erikgrave1
New Member
- Joined
- Jul 22, 2015
- Messages
- 9
Hi,
I´m struggling with extracting data from an XML file. All I need is the "Status" of each SID listed in XML file, where can be up to 50 different SIDs. This is the example of XML file.
I have solved extracting 1 status (function is down below), but it is really very slow (1 SID = 1 second, and I need to check around 50.000 in total). So my function will assign correct Status according the SID (S12345678 will be "in operation", S23456789 will be "out of operation" etc.) I think there should be used "For each ..." somehow.
Thank you very much. Your help is really appreciated. And even if there will be no solution for me, the code below will probable help someone
This is the XML file (I have added space after the <) :
This is my function (working for 1 SID) :
I´m struggling with extracting data from an XML file. All I need is the "Status" of each SID listed in XML file, where can be up to 50 different SIDs. This is the example of XML file.
I have solved extracting 1 status (function is down below), but it is really very slow (1 SID = 1 second, and I need to check around 50.000 in total). So my function will assign correct Status according the SID (S12345678 will be "in operation", S23456789 will be "out of operation" etc.) I think there should be used "For each ..." somehow.
Thank you very much. Your help is really appreciated. And even if there will be no solution for me, the code below will probable help someone
This is the XML file (I have added space after the <) :
Code:
[TABLE]
<tbody>[TR]
[TD]< ?xml version="1.0" encoding="UTF-8"?>[/TD]
[/TR]
[TR]
[TD]-< root>[/TD]
[/TR]
[TR]
[TD]-< record type="tsacinv/system">[/TD]
[/TR]
[TR]
[TD]< status>in operation< /status>[/TD]
[/TR]
[TR]
[TD]< systemid>S12345678< /systemid>[/TD]
[/TR]
[TR]
[TD]< /record>[/TD]
[/TR]
[TR]
[TD]-< record type="tsacinv/system">[/TD]
[/TR]
[TR]
[TD]< status>out of operation< /status>[/TD]
[/TR]
[TR]
[TD]< systemid>S23456789< /systemid>[/TD]
[/TR]
[TR]
[TD]< /record>[/TD]
[/TR]
[TR]
[TD]-< record type="tsacinv/system">[/TD]
[/TR]
[TR]
[TD]< status>in operation< /status>[/TD]
[/TR]
[TR]
[TD]< systemid>S34567890< /systemid>[/TD]
[/TR]
[TR]
[TD]< /record>[/TD]
[/TR]
[TR]
[TD]< /root>[/TD]
[/TR]
</tbody>[/TABLE]
This is my function (working for 1 SID) :
Code:
Public Function statusAM(S As Range) As Variant
myURL = "" '<- here is the link for getting the XML file, using variable "S" from a cell for SID added to the link
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.SetProperty "SelectionLanguage", "XPath"
xmlDoc.async = False
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", myURL, False
.Send
xmlDoc.LoadXML .responseText
End With
Set NodeXML = xmlDoc.getElementsByTagName("status")
statusAM = NodeXML(0).text
End Function