Avatar of RWayneH
Flag for United States of America

asked on 

Pull value from XML that has four of the same <Profile> in it?

I use the following code is what I use to get a value from an xml file (attached) however now I am trying to get some data from the PurchaseOrder/Profile/  but there are 4 different Profiles?  How would I get the SoldTo, ShipTo values when there are 4 Profiles to choose from?  In the example xml all the values are the same, but they will have different values.  I am trying to use: Set node1, to pulled the 60520 value from the SoldTo  (node and node2 work fine.  Any ideas?  Is the Profile[0] = the first, Profile[1] = the second ? as in the node2 that is working?

	Set xmlDoc = CreateObject("Microsoft.XMLDOM")
		xmlDoc.Async = False
		On Error Resume Next
		Set node = xmlDoc.SelectSingleNode("Envelope/PurchaseOrder/Header/RequestedDate/text()")
		Set node1 = xmlDoc.SelectSingleNode("Envelope/PurchaseOrder/Profile/Type/Code/text()")  
			DoRec = node1.NodeValue
		If node > 1 Then
			ReqDT = node.NodeValue
			MyMonth=Month(ReqDT)'grabs month value from NewDate
			MyDay=Day(ReqDT)	'grabs day value from NewDate
			MyYear=Year(ReqDT)	'grabs year value from NewDate
			FormattedDate=MyMonth&"/"&MyDay&"/"&MyYear	'concatinates values into a new value called FormattedDate
			If FormattedDate = "12/30/1899" Then
				FormattedDate = ""
			End If
			DataTable.Value("ReqDT","Global") = FormattedDate
		End If
		Set node2 = xmlDoc.SelectSingleNode("Envelope/PurchaseOrder/Profile[0]/Code/text()")
		DOR2 = node2.NodeValue
		DataTable.Value("DOR","Global") = DOR2		

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon