Jump to content

Recommended Posts

Posted

I was converting Beth Massi's VB example of doing XLINQ from Linq to SQL to create a geoRSS to use with virtual earth or google maps.

 

http://blogs.msdn.com/bethmassi/archive/2007/12/03/northwind-meets-virtual-earth-generate-ve-maps-with-linq.aspx

 

I am having some problems getting Namespacing to work which is making IE 7 detect it as an invalid feed and Firefox shows me the xml happily:

 

**

Northwind Customer Locations

 

*

Jaime Yorres

87 Polk St. Suite 5, San Francisco

-122.417958

37.777419

 

 

 

 

Heres the current state of things in C# (from GeoRss.aspx):

 

protectedvoidPage_Load(objectsender, EventArgse)

{

vardb=newNorthwindDataContext();

vargeoRSS=

newXDocument(

newXDeclaration("1.0", "utf-8", "yes"),

newXElement(

"rss",

newXAttribute("version", "1.0"),

newXElement("channel",

newXElement("title", "Northwind Customer Locations")

, newXElement("link"),

fromcustomerindb.Customers

letDesc=string.Format("{0}, {1}", customer.Address, customer.City)

letAddress=string.Format("{0}, {1}, {2} {3}", customer.Address, customer.City, customer.Region, customer.PostalCode)

wherecustomer.Country=="USA"&&customer.Region=="CA"

selectnewXElement("item",

newXElement("title", customer.ContactName),

newXElement("description", Desc),

GetGeoCode(Address).Descendants()

)

)

)

);

Response.ContentType="text/xml";

Response.Write(geoRSS.ToString());

*

}

XElementGetGeoCode(stringaddress)

{

varurl="http://geocoder.us/service/rest/?address="+Server.UrlEncode(address);

XNamespacegeoNamespace="http://www.w3.org/2003/01/geo/wgs84_pos#";

vargeo=XElement.Load(url);

varpoint=geo.Element(geoNamespace+"Point");

returnnewXElement(geoNamespace+"location",

newXElement(geoNamespace+"long", point.Element(geoNamespace+"long").Value),

newXElement(geoNamespace+"lat", point.Element(geoNamespace+"lat").Value)

);

}

 

 

 

 

 

 

 

 

 

 

 

 

More...

 

View All Our Microsft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...