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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

parsing weather channel xml file using linq

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
 Hi I never used linq before and i'm having trouble parsing the xml file at  http://xoap.weather.com/search/search?where=" + strCityName.ToString(); I used to use a dataset but since trying to change my site to mvc, i thought i would use linq to xml, but after 2 days have still not found success. i have a class called: public class WeatherCityBLLModel { public string loc { get; set; } public string loc_id { get; set; } } and then a class called public class WeatherCityDALModel { public static List<WeatherCityBLLModel> GetLocation(string strCityName) { XDocument doc = XDocument.Load("http://xoap.weather.com/search/search?where=" + strCityName.ToString()) return doc; <<< Does not work } } How do i get the data from xoap.weather and pass it to my controller Any help appreciatedGeorge        

View Complete Post

More Related Resource Links

Event not raised while parsing xml file



In Visual Studio 2010 ASP.NET 4.0

I want to write a procedure to validate a xml file with a xsd. I found some examples on the web but the one i chose does not work as attended. The example uses XmlReader with a XmlReaderSettings and a ValidationEventHandler.

Here is the code

Protected Sub VerifyDes(ByVal filename As String)

        Dim xslDes As XmlReaderSettings = New XmlReaderSettings()
        xslDes.Schemas.Add("", "http://www.mysite.com/xsd/ValidData.xml")
        xslDes.ValidationType = ValidationType.Schema
        xslDes.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings

        AddHandler xslDes.ValidationEventHandler, AddressOf xslDesValidationEventHandler

        Dim des As XmlReader = XmlReader.Create(filename, xslDes)

        While (des.Read())

        End While

    End Sub

    Protected Sub xslDesValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)

        'some code here
    End Sub

I tested this procedure with a xml file which was well formed but contained some elements which were not conform to the xsd.

No event or error occured. It said the file was valid.

Then i tested with a badly formed file. A XmlException was raised but nothing happened with the ValidationEventHandler.

It seems lik

How to MAP Tables in Linq .dbml file

I am using VS 2010I've created LiNQ .dbml file via   .. Model>Add New Item>Data>LINQ to SQL ClasesI've put table on designer surface using drag & drop.I've done all this from one tutorial. There Is Mapping with arrows between tables in tutorial. How can i do this.. ???Can Any one Help Me Please..Thanks

Regarding Ui1 data type parsing in xml file

Hi all, I am sending data to host application in the xml file format given below <communicationData deviceStatus="D0"><communicationData> where "deviceStatus" is ui1 data type. The host application  throws a error " error: parsing "D0" as ui1 datatype ". I have tried to send deviceStatus value in decimal format as well but host application is not resposding correctly. If the hex value does not contain any alphabet then host application respond perfectly fine but if hex value contain any alphbet then host application throws error " error parsing "D0" as ui1 datatype" Can any one please tell me how to convert hexvalue(with alphabet) to Ui1 data types Thanks In advance Ravish Kumar      

LINQ to SQL Compact db, file copy issue

Our application uses LINQ and SQL compact database .sdf file as datasource.  It is using Miscrosoft SQL Server Compact 3.5 SP 1 and .NET Framework 3.5 SP1. We store our application's project data into a .sdf file.  When our application opens a .sdf file (e.g. projectA.sdf), it will make a temporary copy of it and open the temporary file instead of the original file.  If we change one table cell value (i.e. one property value of an object that is created by LINQ), and call DataContext.SubmitChanges(ConflictMode.ContinueOnConflict), and then call File.Copy(DataContext.Connection.Database, filename, true); to copy the temporary file back to the original file (replacing the original one).   We found that the table value is not changed in projectA.sdf.  But in the temporary copy, the value is changed.  If we re-open db connection by calling DataContext.Connection.Close(); DataContext.Connection.Open(); right before calling File.Copy(), the changed value is copied successfully to projectA.sdf. If we do a lot of value changes in the database, or adding / deleting table row, then submit changes.  Without re-opening the db connection, after File.Copy(), the projectA.sdf have those changes copied. This strange behaviour looks like the temporary db file is cached.  For a small change, the cached version is not changed.  The File.Copy() use t

parsing tab delimited spanish characters file


Using vb.net/asp.net 2005.

another spanish character issue:  I am parsing special spanish characters, removing the tildes (EX:  "ñ" becomes "n") that customers send us in files, in tab delimited files that is.

When the characters are valid spanish characters (like "ñ") then this is not an issue, however some of the files that we get have characters such as:


Which should actually be:


Has anyone seen this and know any solution?  The "ñ" is fine but I am not certain what to do about the "±".

this is only one example, other spanish characters are listed as a question mark "?" so this is causing some issues.



LINQ to SQL Classes (dbml file) across multiple websites issue



I have a single LINQ to SQL Classes (dbml file) compiled in a Class Library that's referenced by 3 websites. Inside that Class Library there's also a class that's using the DBML to manipulate data.

At one point it needs to save in a user table the user info (firstname, lastname, email). SOMEHOW (!?) two of the 3 webapps saves email instead of firstname and viceversa while the other 1 saves them correctly ! The one compiled last seems to be the one saving correctly.

There's no code error as I have debugged this multiple times. The values are assigned correctly but before the SubmitChanges() call the data inside the database object is corrupted.

Now, I have already fixed this locally by putting every website in a separate AppPool (which also needs to be set to "Classic" and not "Integrated". However I really don't want to bug the client with such IIS changes so I'm looking for another workaround !

Please Help!



Download a File from a Database Using LINQ to SQL


I have used AsyncFileUpload AJAX control to upload a file to a column in a SQL Server database using LINQ to SQL.  Below is the code.  How do I retrieve the document and allow the user to save to local drive using a Save As Dialog box using LINQ to SQL?  This is ASP.NET web application.  The DocumentFileContent database column is a Image SQL Server data type.  Thanks

var VRRRMDataDataContext = new VRRRMDataDataContext();

VRRRMWeb.AllUsers.Document custDocument = new VRRRMWeb.AllUsers.Document
   DocumentFileName = AsyncFileUpload1.FileName,
                        DocumentDescription = txtDocmentDescription.Text,
                        DocumentFileContent = AsyncFileUpload1.FileBytes,

Linq to save file on database


I need to show an AsyncFileUpload in insert template for the listview and bind its FileContent property to the Content property in my AttachedFile Object (that linq created when it mapped my AttachedFile Table in the database)

I've no idea how to go about wiring all this up. Plz Help!

Oracle.DataAccess.Client.OracleException: ORA-03113:end-of-file on communication channel in Oracle 1


ORA-03113: end-of-file on communication channel

Exception details: Oracle.DataAccess.Client.OracleException: ORA-03113:end-of-file on communication channel

 My database is Oracle 10g, I am using .NET Framework 3.5 with Visual Studio 2008.

 It happened only once when first time in the morning I open my URL in my test server then this error popup at very first page of my site.

Next time onwars it work perfectly fine.

 Any Idea friends, Have you face the similar error, please tell me in details.



Parsing a configuration file.


I have a configuration file which looks like this..

<?xml version="1.0"?>
		<add key="abc" value=http://msn.net/>
		<add key="xyz" value=http://google.com />
      <setting name="getCommunity" serializeAs="String">
      <setting name="Real_Subsciber" serializeAs="String">

I need to parse this configuration file of different application and store the values in key value pair like

1> abc,http://msn.net

2> xyz,http://google.com




Can any one help me out with

Linq query to text file


Hi all, when i want to write the outcome of a linq query to a texfile I only get the query expression instead of the result of the query;

SELECT [t0].[VoertuigModelreeks] AS [model], [t0].[VoertuigMerk] AS [merk], [t0].[VoertuigVolgendeAfspraakMaken] AS [afspraak]
FROM [dbo].[tbl_voertuigen] AS [t0]
WHERE [t0].[VoertuigModelreeks] = @p0

Any idea what i am doing wrong?




Unexpected end of file while parsing Name has occurred.




I have created a infopath 2007 form and publish to sharepoint library. Library has a workflow attached with it, infopath form has multiple dataconnections both sharepoint and webservice. When i open the form it get the correct data and no error comes i press submit button and form is saved without any issue/error. All data is saved corretly workflow starts properly and task\emails are sent. But when i open the saved from again it opens correclty but when close button is pressed an error is poped:


Unexpected end of file while parsing Name has occurred. Line 1, position 260.

System.Xml.XmlException: Unexpected end of file while parsing Name has occurred. Line 1, position 260.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
at System.Xml.XmlTextReaderImpl.ParseEndElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequen

Playing with Linq grouping: GroupByMany?

One of its features is grouping. Many people understand grouping like it is defined in Sql. Linq is implementing grouping quite the same way. Let's discover this syntax and how to make consecutive groups easier.

LINQ : Implementing IN and NOT IN

I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

101 LINQ Samples Tutorials

101 LINQ Example with sample code snippets....This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

Linq to Sql CompiledQuery container

Ok now let's go. Here is just a little trick but with some interesting patterns that could be useful in some other contexts not connected to Linq to Sql.

When using Linq expressions, like with Linq to Sql, translating the expression into something else (sql for example) is taking time and resources. Sometimes it's negligible, sometimes not...
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