473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1760

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

Similar topics

3
by: John R. | last post by:
I have an application written in C# and i am using MS XML DOM! I have a document with the following structure (only the <DicEntry> - Elements are important): <NewDataSet...
3
by: muscha | last post by:
Hi All, I have this weird problem. I have an xml document and tried to do an XPath query to it. If I use the SelectSingleNode method it throws an exception but it works with SelectNodes method....
4
by: Paul M | last post by:
Larry, i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below, it finds the correct number of cities in the...
6
by: David Thielen | last post by:
Hi; I am calling SelectSingleNode("/xml/s:Schema/s:ElementType/@name") where "/xml/s:Schema/s:ElementType/@name is a legit xpath statement (xml is the name of the rootnode) and that xpath...
4
by: Edo | last post by:
Hi, I've xml file like this: <?xml version="1.0" encoding="utf-8" ?> <strings> <component name="commesse"> <form name="dettagli"> <data name="open" description="">Open</data> <data...
0
by: Savaticus | last post by:
This is VBScript centric I have an issue where in windows 2k the selectSingleNode method returns values as expected but in Windows XP I get an error Object Required:...
3
by: Jonathan | last post by:
Hi, I use a XML-Doc with a Namespace like the following example: <HomedResources xmlns=http://schemas.microsoft.com/RtcServer/2002/11/dbimpexp Version="3"> <HomedResource...
1
by: Angela | last post by:
I am getting an error when I attempt to access a node with SelectSingleNode(): "The expression passed to this method should result in a NodeSet." I understand there is some confusion when you have...
5
by: Amadej | last post by:
Hello everyone, I need some advice on which class to use when working with an XML file in a specific way. Basically I am writing a program, that needs to save it's state into a file, so it can...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.