473,548 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with <selectsingleno de> method.

1 New Member
I am trying to parse the xml document using selectsinglenod e 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 1785

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

Similar topics

3
6028
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
3
14866
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. Is this a known problem with XPath and SelectSingleNode? Code snippet: <snip>
4
1665
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 xml file, but repeats the first one 3 times. I'm sure its something minor but i just cant seem to figure it out. here is the XML, and source code...
6
7793
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 statement works fine on the document in XmlSpy. However, when I call this is .NET 1.1, I get the following exception: XPathException {"Namespace...
4
1513
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 name="close" description="">Close</data> <data name="exit" description="">Exit</data> </form>
0
1204
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: 'xmlDoc.selectSingleNode(...)' Any help would be appreciated. Here is my code that realtes to this issue:
3
3295
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 UserAtHost="PBoul@team.de" Enabled="1" VersionPermission="10" VersionContact="25" DisplayName="Boullay, Peter" Email="PBoul@team.de" Phone="+88
1
6194
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 to state a namespace in the xpath. Can the node be accessible by the xpath specified? Thanks. XmlDocument xmldoc = new XmlDocument();
5
1729
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 be read when it starts up (based on where it ended). It's just 3 elements, with a short text and a number associated to it. Something like this: ...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.