Note that there are some explanatory texts on larger screens.

plurals
  1. POlooping through items using xPath
    primarykey
    data
    text
    <p>I am tryng to loop through an xml doc and I am still getting the first element in the second iteration, not sure what I am missing. Can anyone help? Pretty new with Xpath</p> <pre><code>string file = HttpContext.Current.Server.MapPath("~/XML/Locations.xml"); Dictionary&lt;string, Location&gt; locationCollection = new Dictionary&lt;string, Location&gt;(); XPathDocument xDocument = new XPathDocument(file); XPathNavigator xPathNavigator = xDocument.CreateNavigator(); foreach (XPathNavigator node in xPathNavigator.Select("//locations/*")) { string value = node.SelectSingleNode("/locations/location/cell").Value; } &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;locations&gt; &lt;location&gt; &lt;locationName&gt;Glendale&lt;/locationName&gt; &lt;street&gt;3717 San Fernando Road&lt;/street&gt; &lt;city&gt;Glendale&lt;/city&gt; &lt;state&gt;CA&lt;/state&gt; &lt;zipcode&gt;91204&lt;/zipcode&gt; &lt;generalManager&gt;DJ Eldon&lt;/generalManager&gt; &lt;phone&gt;(818) 552‐6246&lt;/phone&gt; &lt;tollFree&gt;(888) 600‐6011&lt;/tollFree&gt; &lt;fax&gt;(818) 552‐6248&lt;/fax&gt; &lt;cell&gt;(347) 834‐2249&lt;/cell&gt; &lt;counterEmail&gt;BUR@Eaglerider.com&lt;/counterEmail&gt; &lt;directEmail&gt;DJ@Eaglerider.com&lt;/directEmail&gt; &lt;/location&gt; &lt;location&gt; &lt;locationName&gt;Chicago&lt;/locationName&gt; &lt;street&gt;1301 S. Harlem Ave.&lt;/street&gt; &lt;city&gt;Chicago&lt;/city&gt; &lt;state&gt;IL&lt;/state&gt; &lt;zipcode&gt;60402&lt;/zipcode&gt; &lt;generalManager&gt;Dave Schnulle&lt;/generalManager&gt; &lt;phone&gt;(708) 749‐1500&lt;/phone&gt; &lt;tollFree&gt;(888) 966‐1500&lt;/tollFree&gt; &lt;fax&gt;(818) 552‐6248&lt;/fax&gt; &lt;cell&gt;(708) 749‐3800&lt;/cell&gt; &lt;counterEmail&gt;ORD@Eaglerider.com&lt;/counterEmail&gt; &lt;directEmail&gt;Dave@Eaglerider.com&lt;/directEmail&gt; &lt;/location&gt; &lt;/locations&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload