.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

Need help parsing out a datestamp

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :.NET Framework
Hi folks, I'm trying to parse a datestamp (that I got from Twitter) but am receiving errors. here's the datestamp: Fri, 27 Aug 2010 22:00:07 +0000 Here's my code: DateTime.ParseExact(MyDateValue, "ddd, dd MMM YYYY HH:mm:ss +ffff", new CultureInfo("en-US")) and here's my error: System.FormatException was unhandled   Message=String was not recognized as a valid DateTime. Anyone fancy taking that on? To make it easy I've provided the code below for a console app that exhibits the problem.   Thanks Jamie using System; using System.Globalization; class Program { static void Main(string[] args) { string MyDateValue = "Fri, 27 Aug 2010 22:00:07 +0000"; var dt = DateTime.ParseExact(MyDateValue, "ddd, dd MMM YYYY HH:mm:ss +ffff", new CultureInfo("en-US")); } } http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | About me

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

CLR Inside Out: Formatting and Parsing Time Intervals in the .NET Framework 4


Learn about enhanced TimeSpan formatting and parsing features coming in the .NET Framework 4, and some helpful tips for working with TimeSpan values.

Ron Petrusha

MSDN Magazine February 2010

Help parsing a string


Hi Everyone, I have the following string

strFullString = "<img src="http://image.weather.com/web/common/wxicons/31/32.gif?12122006" alt="" />Sunny, and 104 &deg; F. For more details?"  


What I would like to do is parse the full string into two strings with the following values

strImgSource = "http://image.weather.com/web/common/wxicons/31/32.gif"

strWeather = "Sunny, and 104 &deg; F."


Ive been pulling my hair out with this one, any help would be greatly appreciated. Thanks!

Parsing WSDL using ServiceDescription

Hi, I am trying to parse a wsdl file using the ServiceDescription class. I've been able to extract some information such as ports and messages. However, I am having trouble accessing the types described in the file. These are the types eclosed within the definitions element. <wsdl:types> <xsd:schema> <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/http/"/> <xsd:complexType name="singleOutAddress"> <xsd:sequence> <xsd:element name="ReferenceID" minOccurs="0" maxOccurs="1" type="xsd:string"> </xsd:element> <xsd:element name="AddressID" minOccurs="0" maxOccurs="1" type="xsd:string"> </xsd:element> <xsd:element name="Score" minOccurs="0" maxOccurs="1" type="xsd:string"> </xsd:element> <xsd:element name="Address" minOccurs="0" maxOccurs="1" type="xsd:string"> </xsd:element> <xsd:element name="PostalCode" minOccurs="0" maxOccurs="1" type="xsd:string"> </xsd:element> <xsd:element name="ErrorCode" minOccurs="0" maxOccurs="1" type="xsd:string"> </xsd:element> <

Server ERROR: An error occurred during the parsing of a resource required to service this request.

I have created one asp.net 2.0 application and created a setup project. I run this setup in my local machine, the application run fine, but i uploaded into online server I met the following parser error.How to solve this error? Kindly help me. Very urgent.. Kamal....

parsing weather channel xml file using linq

 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        

XML Parsing Error: no element found

I had an old SQL server  2008 instance removed and reinstalled SQL server, SSAS, SSRS all together.   When trying to log onto Report Server, I am seeing following error.  can you hel? thanks     XML Parsing Error: no element found Location: http://myservername:8080/Reports/Pages/Folder.aspx Line Number 1, Column 1:

Parsing a SQL query

I am trying to parse a SQL select query.  The idea is to pull out the field names in the query to use them in a lookup to get the units for each field.    The problem is that I need to put units on the columns, but do not know in advance which fields are being queried.  People can type in a free hand query using the field names, "as", "sum(field)", "count(field)", etc.    I am new to regular expressions.  Has anyone done anything like this, or could point me to an example that I could use to get started?   Any help would be great.   Thanks.   David

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      

Parsing XML data

Hello,I am using YQL! for one of my projects: http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22YHOO%22%2C%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22%29&format=xml&env=store%3A%2F%2Fdatatables.org%2FalltableswithkeysHow can I get the following response for the results node in an object? Any ideas on the best way to approach this?

Parsing XML RSS Data

Hello, I am looking to make a small project that can take an RSS feed that is stored in XML format (i.e. http://www.bbc.co.uk/radio1/rss/rss_radio1.xml) and display it on my asp.net page. A simple XML Datasource does not seem to accept nor like a url as the defined source. How can I make an ASP.NET page that will grab data from this remote XML source and display it?

'System.ExecutionEngineException' occurred in WindowsBase.dll parsing Run in separate thread

Receiving the above exception when attempting to fire off a BackgroundWorker and parse the FlowDocument via Run. Sometimes does not reference WindowsBase...as such Exception of type 'System.ExecutionEngineException' was thrown. Some key things are that if I run the exact same code on the UI thread there are no issues at all. If I run the code as a BackgroundWorker and the document is very small, no issues will surface either...although that may be a timing issue masking itself. Below is the entire parsing class...things begin in the method at the bottom the ParseRuns method.   public class Parser : IParser { private void OnDoWork(object sender, DoWorkEventArgs e) { ParseRuns(e); } private void OnWorkComplete(object sender, RunWorkerCompletedEventArgs e) { ParserHandler handler = _parsingHandler; if (handler != null) handler(this, new ParserArgs((e.Result as List<Data>)[0].Words, (e.Result as List<Data>)[1].Words, e.Error)); } #region IParser Members private ParserHandler _parsingHandler; event ParserHandler IParser.ParsingCompleted { add { _parsingHandler += value; } remove { _parsingHandler -= value; } } void IParser.Parse(FlowDocument origText, FlowDocument modifiedText) { //nothing to do with null if (origText == null || modifiedText == null) return; //ParseUIThread(origText, mo

Incomplete/truncated data Serialized to disk. Error:End of Stream encountered before parsing was com

Greetings!! i have a dataset which is constantly serialized & deserialized by multiple threads (in a thread safe manner using lock statement) using System.Runtime.Serialization.Formatters.Binary.BinaryFormatter (.net 2.0). The Code below works pretty fine but in some rare scenarios it gives the above exception while deserializing. public void SerializeData(string path, DataSet currentData) { dataStream = new FileStream(path , FileMode.Create, FileAccess.ReadWrite); try { biFormatter.Serialize(dataStream, currentData); } finally { dataStream.Flush(); dataStream.Close(); } } DataSet DeserializeData(string path) { dataStream = new FileStream(path , FileMode.Open, FileAccess.ReadWrite); DataSet storedDataSet = new DataSet(); storedDataSet.Locale = CultureInfo.InvariantCulture; try { storedDataSet = (DataSet)biFormatter.Deserialize(dataStream); } finally { dataStream.Close(); } return storedDataSet; } When i observed the serialized file i realized the file had some in incomplete/truncated data. The truncated file loo

Parsing flat files or tab delimited files.csv with Visual Studio and or Biz Talk Server.

Hello msdn community, I need help with finding the proper Microsoft application that will allow me to parse a .csv  flat file / tab delimited file for its text, The data will be queried client side dynamically populated to my web page form with Visual Studio 2008.  I have read that a MS Biztalk Server will perform a similar function, I am still checking on this. Has anyone in the community had experience with flat file parsing with Microsoft software and or hardware? Any and all help will be appreciated in helping me resolve this issue because I am not well versed with the Microsoft products. Spidaweb Web Designer /Webmaster Virtual Web Dev, LLC.

Parsing the email body content in a SPEmailEventReceiver class

Hi All, 1. I have an email enabled Sharepoint list which have certain fields like Fname,Lname,Address,Phonenumber   2. Someone will send an email to this list   the email body like this   Fname: Mohammed Lname:Hanif Adress:CA Phonenumber:001234   Now i have to read this body and create a new item in this List where the list fields value will be like this Fname: Mohammed Lname:Hanif Address:CA Phonenumber:001234 Created BY: Email Sender   I can parse the subject and sender to list columns but my problem is to read the content of the Email Body identify the Field value and copy it to corresponding List Fields.   Any help is much appreciated. Regards, Hanif Hanif

REST Starter Kit - parsing issue with ampersand in element

We built a REST web service using the REST Starter Kit.  We want to allow XML post elements that contain ampersands.   How can we modify the code to have the parsing at the element level so that when an XML post element contains an ampersand we don't generate an error?

Parsing Data Into Variables

Hi All, At present I have a number of jobs that are scheduled and executed through SQL Agent.  The Agent is set up to execute batch files that parse data into variables contained within the packages themselves. Is there anyway that I can get data into variables without using batch files just to make the process more integrated in SSIS rather than starting the process in SQL Agent to start the job, coming out of SQL Server to execute the batch file and then back into SQL Server to run the packages detailed in the batch files? I would like to point out that this is something I have inherited not built myself. Many Thanks B_G
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