.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

XPath expression not working for Google Maps return XML

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
 
I have this XMLdocument:<kml><Response><name>3051,netherlands</name><Status><code>200</code><request>geocode</request></Status><Placemark id="p1"><address>3051 Rotterdam, The Netherlands</address><AddressDetails Accuracy="5"><Country><CountryNameCode>NL</CountryNameCode><CountryName>Nederland</CountryName><AdministrativeArea><AdministrativeAreaName>Zuid-Holland</AdministrativeAreaName><Locality><LocalityName>Rotterdam</LocalityName><PostalCode><PostalCodeNumber>3051</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails><ExtendedData><LatLonBox north="51.9497984" south="51.9402954" east="4.4907255" west="4.4656367"/></ExtendedData><Point><coordinates>4.4767883,51.9458650,0</coordinates></Point></Placemark></Response></kml>I used this site: http://www.xmlme.com/XpathTool.aspxwhere I enter the expression: "kml/Response/Placemark/Point/coordinates"I then get the right value. HOWEVER, when I place this code in .NET, the xpath expression returns nothing:req = HttpWebRequest.Create("http://maps.google.com/maps/geo?output=x


View Complete Post


More Related Resource Links

Image gallery with EXIF and Google maps?

  

I am trying to put together an image gallery display. I am guessing it will need to be a customer control but I am not sure.  So I figured I would ask on the best way to approach this. When the gallery is loaded I want to have one image displayed with thumbs underneath. On the right side I would like to display EXIF data and underneath that a small google map if there is geolocation tagged with the picture. I figure I will probably need to store the gallery info in a database with caption and description.  Maybe even searchable tags if I get cheeky later. 

So should I be using an ajax gallery to display the images and if so how to pass the EXIF and geolocation to the other controls? Or do i pull in all the info into some sort of dataset and then parse it out to a custom control.  I am still fairly new to ASP but I have a fairly good understanding.  Should be an intersting project if nothing else.  Any thoughts.


Thanks


How to display Polygons from sql server 2008 on top of google maps

  
hi every one,This is the situation I am facing...I have a table in sql server 2008 database that contains map of a village in the form of polygons. I want these polygons to be displayed on top of google maps. Can any body suggest how to start of ?? Thanks in advanceRk

Google Maps Tutorial

  
Because it's best to learn from examples, here is a complete listing of all the functionalities GoogleMaps.Subgurim.NET offers .

Each example is made up of an explanation of the element, a map example, and the code corresponding to that example.
Periodically we will be adding to the list!

maintainscrollpositiononpostback is not working in Google Chrome 5.0.353.70 beta

  
All --I think that sometimes maintainscrollpositiononpostback is not working in Google Chrome 5.0.353.70 beta.Has anyone else experienced this?Does anyone have a fix for this?Does anyone have an alternative for this?Please advise.Thank you.-- Mark Kamoski

xmldatasource and xpath expression evaluation

  
Hi, I am working with XMLdatasource and trying to consume a XML file. Now problem is there are scenarios when a link is not available in the xml file. Like in the e.g. below: <a href='<%# XPath("link") %>' >  </a>  say "link" can or cannot be there in the file. Now when "link" is missing, this expression throws exception. How can I handle this exception so that it continues loading page normally or can I check "link" existence somehow? Thanks.

Return QueryString id to a FB tag not working

  
Here's my FB tag Asp.net<fb:like href="https://www.mysite.com/alumni/eventDetails.aspx?dateID=<%# getID() %>" width="200"> </fb:like> JavaScript:<script> window.fbAsyncInit = function () { FB.init({ appId: 'your app id', status: true, cookie: true, xfbml: true }); }; (function () { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); } ()); </script> And here's the getID() code behind:protected string getID() { string strID = Request.QueryString["dateID"].ToString(); return strID; } For some reason, I did not get an ID in the Facebook like link.

Help needed on XPath Error: System.Xml.XPath.XPathException: Expression must evaluate to a node-set.

  
Im trying to determine if a value already exists in an XML file. In this case I want to know if there's a node "id" with value 3. But I cant figure out how...XML:<root><data><compare><locations><id>3</id><id>5</id></locations></compare></data></root>XSL:xmldoc.SelectSingleNode("//root/data/compare/locations/id=""3""")Error:XPath Error: System.Xml.XPath.XPathException: Expression must evaluate to a node-set.

adding onload event from code behind for Google Maps

  
Im working with Google maps start turoail: http://code.google.com/apis/maps/documentation/javascript/tutorial.html#HelloWorldAs you can see there's a line: <body onload="initialize()">Now since, I want to have Google Maps on page A.aspx within a masterpage main.master, I dont have the <body> tag available to me in the A.aspx page.I preferably DONT want to have the body tag as runat="server", since Google Maps is not relevant for all pages and I dont like a server control when its not needed as they slow things down (even a bit).I tried this in A.aspx.vb, but it didnt work:Dim javaScript As New StringBuilder        javaScript.Append("<script type='text/javascript'>")        javaScript.Append("window.document.body.onload = initialize();")        javaScript.Append("</script>")        Me.Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "BodyLoadUnloadScript", javaScript.ToString())How can I add the onload event from code behind?

An Expression Blend behavior to return the TreeView SelectedItem

  

Like all developers I eventually needed the SelectedItem of a TreeView in my ViewModel.  My requirement involved allowing a MenuItem to be enabled or disabled depending upon which TreeView node was selected.  My solution is a behavior based off of a forum answer provided by the good Dr. WPF.  The code  for the TreeViewSelectedItemBehavior class and some simple examples of using it are below:  Any suggestions for improvements are welcome. 

    public class TreeViewSelectedItemBehavior : Behavior<TreeView>
    {
        public TreeViewSelectedItemBehavior()
        {
        }
        public static readonly DependencyProperty SelectedTreeViewItemProperty = DependencyProperty.Register("SelectedTreeViewItem", typeof(System.Windows.Controls.TreeViewItem), typeof(TreeViewSelectedItemBehavior), new PropertyMetadata(null));

        public System.Windows.Controls.TreeViewItem SelectedTreeViewItem
        {
            get { return this.GetValue(TreeViewSelectedItemBehavior.SelectedTreeViewItemProperty) as System.Windows.Controls.TreeViewItem; }
            set { this.SetValue(TreeViewSelectedItemBehavior.SelectedTreeViewItemProperty, value); }
        }

        protected override void OnAttached()
        {
            base.OnAttached();
            Associate

help with xpath expression needed

  

I get an "Object reference not set to an instance of an object." with the following:

XML document
<response>

<lst name="facet_counts">
<lst name="facet_queries"/>

<lst name="facet_fields">

<lst name="hasphoto">
<int name="true">4</int>
<int name="false">2</int>
</lst>

</lst>
<lst name="facet_dates"/>
</lst>
</response>


XPath expression:
objXML.SelectSingleNode("response/lst[@name=""facet_counts""]/lst[@name=""facet_fields""]/lst[@name=""hasphoto""]/int[@name=""true""]").Value
OR
objXML.SelectSingleNode("response/lst[@name=""facet_counts""]/lst[@name=""facet_fields""]/lst[@name=""hasphoto""]/int[@name=""true""]").Innertext

But when I test it here: http://www.xmlme.com/XpathTool.aspx

The correct value (4) is returned...:s


MSXML2 or XmlDocument ? using an union Expression in XPath 2

  


Hallo, I'm using XPath for a long time by MSXML, now I tested some xml access with XmlDocument and have a problem with using XPath2.
 

This one works:

DOMDocument doc2 = new MSXML2.DOMDocument();
MSXML2.doc2.loadXML(xmlText);
MSXML2.IXMLDOMNode node = doc2.selectSingleNode("bla1/bla2/(ytype|xtype)");



This one works not:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlText);
XmlNode node = xmlDoc.SelectSingleNode("bla1/bla2/(ytype|xtype)");


Is there any explanation? Which class should I use in .NET for XPath 2 XML access ?

Best regards

Roy


MSXML2 or XmlDocument ? using an union Expression in XPath 2

  


Hallo, I'm using XPath for a long time by MSXML, now I tested some xml access with XmlDocument and have a problem with using XPath2.
 

This one works:

DOMDocument doc2 = new MSXML2.DOMDocument();
MSXML2.doc2.loadXML(xmlText);
MSXML2.IXMLDOMNode node = doc2.selectSingleNode("bla1/bla2/(ytype|xtype)");



This one works not:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlText);
XmlNode node = xmlDoc.SelectSingleNode("bla1/bla2/(ytype|xtype)");


Is there any explanation? Which class should I use in .NET for XPath 2 XML access ?

Best regards

Roy


google maps

  

<script type="text/javascript">

     function showLocation() {
         geocoder.getLocations(document.forms[0].address1.value, function (response) {
             if (!response || response.Status.code != 200) {
                 alert("Sorry, we were unable to geocode the first address");
             }
             else {
                 location1 = { lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address };
                 geocoder.getLocations(document.forms[0].address2.value, function (response) {
                     if (!response || response.Status.code != 200) {
                         alert("Sorry, we were unable to geocode the second address");
                     }
                     else {
                         location2 = { lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address };
                         calculateDistance();
                     }
                 });
             }
         });
     }

     function calculateDistance() {
         try {
             var glatlng1 = new GLatLng(location1.lat, location1.lon);
             var glatlng2 = new GLatLng(location2.lat, location2.lon);
             var miledistance = gl

Filter expression not working

  

Hi, I am using a GridView and I require the user to be able to filter using 2 controls. One simply filters the type of row - there is a column called action, and the user selects one of the distinct values from the database in a dropdown box, and the gridview only displays the rows with that value in the action column. On it's own this works perfect.

But I am also adding a textbox where the user can type in an ID of either the 'itemID', or the 'parentID'. This works fine even with the previous control.

Problem is, the dropdown box does not work when the textbox is empty (i.e. all ID's are being shown). If I choose a value and click Submit, it just doesn't do anything. Now if I am filtering by ID and then choose a value from the dropdown box, it works perfect.

Here is my filter expression and parameters of the datasource:

 

 <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
        ConnectionString="cleared for privacy" 
        SelectCommand="SELECT * FROM [Audit] WHERE ([source] = @source)" FilterExpression="action like '{0}%' and (itemID like '{1}' or parentID like '{1}')"> 
        <SelectParameters> 
            <asp:Parameter DefaultValue="LOGISTICS" Name="source&quo

How to retrieve conditional XML data using XPath Expression

  
I have a XMLDataSource somewhat like:
<bookstore>
 <author>author1</author>
 <publication>publication1</publication>
 <book>
  <genre>Thriller</genre>
  <name>ABC</name>
 </book

How can I use xml SelectNodes to parse google maps xml ?

  
I'd like to parse 
http://maps.google.com/maps/geo?output=xml&key=<your_google_api_key>&q=<city_state>

I can't find any example on the net which uses

doc.Load(url);
   
XmlNodeList nodes = doc.SelectNodes("/GeocodeResponse/result/geometry/location/lat/");

Dynamic Google Maps Help

  

This works fine for me!

sb.Append(

"if(GBrowserIsCompatible()) {" & vbLf & vbTab & vbTab & "function ShowMap() {" & vbLf & vbTab & vbTab & vbTab & "var map = new GMap(document.getElementById(""map"")); map.setMapType(G_PHYSICAL_MAP ); " & vbLf & vbLf & vbTab & vbTab & vbTab)

 

But I'm DYING on adding this line...

sb.Append(

 

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend