469,883 Members | 1,241 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,883 developers. It's quick & easy.

Need Help with <selectsinglenode> method.

I am trying to parse the xml document using selectsinglenode method.
I am doing this using Visual Foxpro
>>>
Expand|Select|Wrap|Line Numbers
  1. loResultXml = CreateObject("Microsoft.XMLDOM")
  2.  
  3. With loResultXml
  4.    .Async = .F.
  5.    .Load(pcXmlFile)
  6.    oPackage = .documentElement.SelectSingleNode("//Package")
  7. EndWith
  8.  
  9. oActivities = oPackage.selectNodes("//Activity")
  10. FOR i = 0 TO oActivities.Length - 1
  11.    oActivity = oActivities.Item(i)
  12.    lcCode = oActivity.selectSingleNode"//Activity/Status/StatusCode/Code").text
  13.    lcDate = oActivity.selectSingleNode("//Date").text
  14.    lcTime = oActivity.selectSingleNode("//Time").text
  15.    lcDesc = oActivity.selectSingleNode"//Status/StatusType/Description").text
  16.  ENDFOR
  17. >>>
  18. The problem is that inside for loop, when i examine the xml content, it shows the correct xml node on each iteration. But selectSingleNode method always gives the data from the first oActivity block, even though oActivity.xml shows totally different xml content. For example, lcCode is always "KB" for all the iteration.
  19. Can somebody give me any kind of suggestion how to attack this problem?
  20. >>>
  21. The following is xml file to be parsed.
  22. >>>
  23. <?xml version="1.0"?>
  24. <TrackResponse>
  25.     <Response>
  26.         <TransactionReference>
  27.             <CustomerContext>Example 1</CustomerContext>
  28.             <XpciVersion>1.0001</XpciVersion>
  29.         </TransactionReference>
  30.         <ResponseStatusCode>1</ResponseStatusCode>
  31.         <ResponseStatusDescription>Success</ResponseStatusDescription>
  32.     </Response>
  33.     <Shipment>
  34.         <Package>
  35.                     <Activity>
  36.                 <ActivityLocation>
  37.                     <Address>
  38.                         <City>AVENTURA</City>
  39.                         <StateProvinceCode>FL</StateProvinceCode>
  40.                         <PostalCode>33180</PostalCode>
  41.                         <CountryCode>US</CountryCode>
  42.                     </Address>
  43.                     <Code>M7</Code>
  44.                     <Description>RECEIVER</Description>
  45.                     <SignedForByName>ELINAM</SignedForByName>
  46.                 </ActivityLocation>
  47.                 <Status>
  48.                     <StatusType>
  49.                         <Code>D</Code>
  50.                         <Description>DELIVERED</Description>
  51.                     </StatusType>
  52.                     <StatusCode>
  53.                         <Code>KB</Code>
  54.                     </StatusCode>
  55.                 </Status>
  56.                 <Date>20070115</Date>
  57.                 <Time>122500</Time>
  58.             </Activity>
  59.             <Activity>
  60.                 <ActivityLocation>
  61.                     <Address>
  62.                         <City>HIALEAH</City>
  63.                         <StateProvinceCode>FL</StateProvinceCode>
  64.                         <CountryCode>US</CountryCode>
  65.                     </Address>
  66.                 </ActivityLocation>
  67.                 <Status>
  68.                     <StatusType>
  69.                         <Code>I</Code>
  70.                         <Description>OUT FOR DELIVERY</Description>
  71.                     </StatusType>
  72.                     <StatusCode>
  73.                         <Code>DS</Code>
  74.                     </StatusCode>
  75.                 </Status>
  76.                 <Date>20070115</Date>
  77.                 <Time>004500</Time>
  78.             </Activity>
  79.             <Activity>
  80.                 <ActivityLocation>
  81.                     <Address>
  82.                         <City>HIALEAH</City>
  83.                         <StateProvinceCode>FL</StateProvinceCode>
  84.                         <CountryCode>US</CountryCode>
  85.                     </Address>
  86.                 </ActivityLocation>
  87.                 <Status>
  88.                     <StatusType>
  89.                         <Code>I</Code>
  90.                         <Description>DESTINATION SCAN</Description>
  91.                     </StatusType>
  92.                     <StatusCode>
  93.                         <Code>DS</Code>
  94.                     </StatusCode>
  95.                 </Status>
  96.                 <Date>20070115</Date>
  97.                 <Time>002900</Time>
  98.             </Activity>
  99.             <Activity>
  100.                 <ActivityLocation>
  101.                     <Address>
  102.                         <City>HIALEAH</City>
  103.                         <StateProvinceCode>FL</StateProvinceCode>
  104.                         <CountryCode>US</CountryCode>
  105.                     </Address>
  106.                 </ActivityLocation>
  107.                 <Status>
  108.                     <StatusType>
  109.                         <Code>I</Code>
  110.                         <Description>ARRIVAL SCAN</Description>
  111.                     </StatusType>
  112.                     <StatusCode>
  113.                         <Code>AR</Code>
  114.                     </StatusCode>
  115.                 </Status>
  116.                 <Date>20070114</Date>
  117.                 <Time>201800</Time>
  118.             </Activity>
  119.             <Activity>
  120.                 <ActivityLocation>
  121.                     <Address>
  122.                         <City>LOUISVILLE</City>
  123.                         <StateProvinceCode>KY</StateProvinceCode>
  124.                         <CountryCode>US</CountryCode>
  125.                     </Address>
  126.                 </ActivityLocation>
  127.                 <Status>
  128.                     <StatusType>
  129.                         <Code>I</Code>
  130.                         <Description>DEPARTURE SCAN</Description>
  131.                     </StatusType>
  132.                     <StatusCode>
  133.                         <Code>DP</Code>
  134.                     </StatusCode>
  135.                 </Status>
  136.                 <Date>20070113</Date>
  137.                 <Time>201800</Time>
  138.             </Activity>
  139.             <Activity>
  140.                 <ActivityLocation>
  141.                     <Address>
  142.                         <City>LOUISVILLE</City>
  143.                         <StateProvinceCode>KY</StateProvinceCode>
  144.                         <CountryCode>US</CountryCode>
  145.                     </Address>
  146.                 </ActivityLocation>
  147.                 <Status>
  148.                     <StatusType>
  149.                         <Code>I</Code>
  150.                         <Description>LOCATION SCAN</Description>
  151.                     </StatusType>
  152.                     <StatusCode>
  153.                         <Code>LC</Code>
  154.                     </StatusCode>
  155.                 </Status>
  156.                 <Date>20070112</Date>
  157.                 <Time>124700</Time>
  158.             </Activity>
  159.             <Activity>
  160.                 <ActivityLocation>
  161.                     <Address>
  162.                         <City>LOUISVILLE</City>
  163.                         <StateProvinceCode>KY</StateProvinceCode>
  164.                         <CountryCode>US</CountryCode>
  165.                     </Address>
  166.                 </ActivityLocation>
  167.                 <Status>
  168.                     <StatusType>
  169.                         <Code>I</Code>
  170.                         <Description>UNLOAD SCAN</Description>
  171.                     </StatusType>
  172.                     <StatusCode>
  173.                         <Code>UL</Code>
  174.                     </StatusCode>
  175.                 </Status>
  176.                 <Date>20070112</Date>
  177.                 <Time>123400</Time>
  178.             </Activity>
  179.             <Activity>
  180.                 <ActivityLocation>
  181.                     <Address>
  182.                         <City>LOUISVILLE</City>
  183.                         <StateProvinceCode>KY</StateProvinceCode>
  184.                         <CountryCode>US</CountryCode>
  185.                     </Address>
  186.                 </ActivityLocation>
  187.                 <Status>
  188.                     <StatusType>
  189.                         <Code>I</Code>
  190.                         <Description>ARRIVAL SCAN</Description>
  191.                     </StatusType>
  192.                     <StatusCode>
  193.                         <Code>AR</Code>
  194.                     </StatusCode>
  195.                 </Status>
  196.                 <Date>20070112</Date>
  197.                 <Time>104800</Time>
  198.             </Activity>
  199.             <Activity>
  200.                 <ActivityLocation>
  201.                     <Address>
  202.                         <City>HOUSTON</City>
  203.                         <StateProvinceCode>TX</StateProvinceCode>
  204.                         <CountryCode>US</CountryCode>
  205.                     </Address>
  206.                 </ActivityLocation>
  207.                 <Status>
  208.                     <StatusType>
  209.                         <Code>I</Code>
  210.                         <Description>DEPARTURE SCAN</Description>
  211.                     </StatusType>
  212.                     <StatusCode>
  213.                         <Code>DP</Code>
  214.                     </StatusCode>
  215.                 </Status>
  216.                 <Date>20070112</Date>
  217.                 <Time>074600</Time>
  218.             </Activity>
  219.             <Activity>
  220.                 <ActivityLocation>
  221.                     <Address>
  222.                         <City>HOUSTON</City>
  223.                         <StateProvinceCode>TX</StateProvinceCode>
  224.                         <CountryCode>US</CountryCode>
  225.                     </Address>
  226.                 </ActivityLocation>
  227.                 <Status>
  228.                     <StatusType>
  229.                         <Code>I</Code>
  230.                         <Description>ARRIVAL SCAN</Description>
  231.                     </StatusType>
  232.                     <StatusCode>
  233.                         <Code>AR</Code>
  234.                     </StatusCode>
  235.                 </Status>
  236.                 <Date>20070112</Date>
  237.                 <Time>023000</Time>
  238.             </Activity>
  239.             <Activity>
  240.                 <ActivityLocation>
  241.                     <Address>
  242.                         <City>STAFFORD</City>
  243.                         <StateProvinceCode>TX</StateProvinceCode>
  244.                         <CountryCode>US</CountryCode>
  245.                     </Address>
  246.                 </ActivityLocation>
  247.                 <Status>
  248.                     <StatusType>
  249.                         <Code>I</Code>
  250.                         <Description>DEPARTURE SCAN</Description>
  251.                     </StatusType>
  252.                     <StatusCode>
  253.                         <Code>DP</Code>
  254.                     </StatusCode>
  255.                 </Status>
  256.                 <Date>20070111</Date>
  257.                 <Time>230000</Time>
  258.             </Activity>
  259.             <Activity>
  260.                 <ActivityLocation>
  261.                     <Address>
  262.                         <City>STAFFORD</City>
  263.                         <StateProvinceCode>TX</StateProvinceCode>
  264.                         <CountryCode>US</CountryCode>
  265.                     </Address>
  266.                 </ActivityLocation>
  267.                 <Status>
  268.                     <StatusType>
  269.                         <Code>I</Code>
  270.                         <Description>ORIGIN SCAN</Description>
  271.                     </StatusType>
  272.                     <StatusCode>
  273.                         <Code>OR</Code>
  274.                     </StatusCode>
  275.                 </Status>
  276.                 <Date>20070111</Date>
  277.                 <Time>183700</Time>
  278.             </Activity>
  279.             <Activity>
  280.                 <ActivityLocation>
  281.                     <Address>
  282.                         <CountryCode>US</CountryCode>
  283.                     </Address>
  284.                 </ActivityLocation>
  285.                 <Status>
  286.                     <StatusType>
  287.                         <Code>M</Code>
  288.                         <Description>BILLING INFORMATION RECEIVED</Description>
  289.                     </StatusType>
  290.                     <StatusCode>
  291.                         <Code>MP</Code>
  292.                     </StatusCode>
  293.                 </Status>
  294.                 <Date>20070111</Date>
  295.                 <Time>182327</Time>
  296.             </Activity>
  297.         </Package>
  298.     </Shipment>
  299. </TrackResponse>
  300.  
Jan 27 '07 #1
0 1562

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by muscha | last post: by
4 posts views Thread by Paul M | last post: by
6 posts views Thread by David Thielen | last post: by
4 posts views Thread by Edo | last post: by
3 posts views Thread by Jonathan | last post: by
5 posts views Thread by Amadej | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.