troubleshooting Question

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

Avatar of RWayneH
RWayneHFlag for United States of America asked on
ProgrammingXML
5 Comments1 Solution144 ViewsLast Modified:
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
		xmlDoc.Load(ListOfFiles)
		
		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
		Err.Clear
		
		Set node2 = xmlDoc.SelectSingleNode("Envelope/PurchaseOrder/Profile[0]/Code/text()")
		DOR2 = node2.NodeValue
		DataTable.Value("DOR","Global") = DOR2		
002.xml
ASKER CERTIFIED SOLUTION
zc2

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros