Posts

Showing posts from October, 2011

Donate

(502)Bad Gateway Returned From HttpWebRequest In C#

The solutions is to set the default proxy for the web request and assign user agent to it as shown below: ListURL = String.Format( "your_xml_feed_or_API_url_sample" ); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ListURL); request.Timeout = 900000000; request.Proxy = HttpWebRequest.DefaultWebProxy; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" ; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); ListingSource = reader.ReadToEnd(); ListingSource = System.Web.HttpUtility.HtmlDecode(ListingSource); Cheers!

Invalid Expanded Name In LINQ to XML

Assuming I am reading this xml file using XLINQ. I encountered an error that says invalid expanded name. As i go through this xml file, i found a node images that contains element tags. The parent node is also an element tag. Since i don't use the images tag, I simply remove it using string manipulations. Below is the xml file and the solution: <element> <id> 2768687195 </id> <title> Customer Service Representative </title> <body> Do you dream of being your own boss and choosing the work you do, when you work and who you work for? </body> <url> http://jobs.myjob.careercenter-servicecrew.html </url> <category> <id> job/customer_service </id> <name> Customer Service &amp; Call Center Jobs </name> </category> <source> <id> www </id>

How To Read Or Parse XML Using LINQ And XLinq In C#

Hello, Here's an example on how to read or parse XML file using LINQ and XLINQ in C#. XML Content: <item> <title> Labor Warehouse Associates - Boston, Massachusetts </title> <link> http//www.BostonRecruiter.com/job_display.php?alpha=17343491 </link> <description> Hudson Group is the #1 airport retailer operating in over 400 retail locations in most major airports, throughout the US and Canada. While we are comprised of many </description> <guid> http//www.BostonRecruiter.com/job_display.php?alpha=17343491 </guid> <joblocation> <jobcity> Boston </jobcity> <jobstate> Massachusetts </jobstate> <jobcountry> United States </jobcountry> </joblocation> </item> C# Code: string url = "your xml or rss link" ; string xmlsource = client.DownloadString(url);

Donate