XLINQ question

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
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/arc...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
 
Back
Top