none
Getting XML elements from a Spatial Data Query(NAVTEQNA) RRS feed

  • Question

  • So I am querying the NAVTEQNA spatial data service. I am able to get the XML file to display and show me the results, but I can't seem to get a single element. Ex. Name, Address, etc.

    Here is my code

    public async void FindPOIItems()
            {
                // Find all previously uploaded MyShops entities located within
                // a certain radius around a point.
                // Custom name of spatial data source created during upload
                string dataSourceName = "NavteqNA";
                // Name of entities in the data source
                string dataEntityName = "NavteqPOIs";
                // Unique access ID assigned to your data source by Bing Maps
                // e.g. f8986xxxxxxxc844b
                string accessId = "f22876ec257b474b82fe2ffcb8393150";
                // Your Bing Maps Spatial Data Services query key.
                string bingMapsKey = myMap.Credentials;
                // Coordinates of the point to search from.
                double SearchLatitude = 47.63674;
                double SearchLongitude = -122.30413;
                // Search radius
                double Radius = 10; // km
                //string entityTypeID = "7011";//hotels
                //string entityTypeID = "9996";//Coffee Shops
                string entityTypeID = "5540";//Petrol/Gasoline Station
                // Setup REST request to query our uploaded customer data
                string requestUrl = string.Format("http://spatial.virtualearth.net/REST/v1/data/{0}/{1}/{2}" +
                  "?spatialFilter=nearby({3},{4},{5})" + "&$filter=EntityTypeID%20EQ%20" + entityTypeID + "&$top=100" + "&key={6}", accessId, dataSourceName,
                  dataEntityName, SearchLatitude, SearchLongitude, Radius, bingMapsKey);
                XDocument response = await GetXmlResponse(requestUrl);
                ProcessEntityElements(response);
            }
    
            public async static Task<XDocument> GetXmlResponse(string requestUrl)
            {
                try
                {
                    WebRequest request = WebRequest.Create(requestUrl);
                    WebResponse response = await request.GetResponseAsync();
    
                    XDocument xmlDoc = XDocument.Load(response.GetResponseStream());
                    return (xmlDoc);
                }
                catch 
                {
                    return null;
                }
            }
    
            private void ProcessEntityElements(XDocument response)
            {
                var q = response.Elements();
                foreach (XElement ele in q)
                {
                    
                    ResultsList.Text += ele.ToString();
                }
            }

    If anyone can help that would be fantastic.

    Thanks

    Tex

    Monday, December 2, 2013 6:31 PM

Answers