Posts

Showing posts from 2015

October Articles

Thank you to all who voted for two of my articles which where listed in top ten on Codeproject.

Doing Delegates Differently part 1 and Using HTMLAgility pack and CSS Selectors.

Doing Delegates Differently

This is an article about using delegates in a way in which you may not have thought of using them before. As I started to write this it became obvious that this would be a long article, so I am splitting in two. This first part is an overview of delegates and how to group functionality and cross cutting concerns with them. Part two will delve into using delegates to create a validator which can validate any type of object dynamically.
Part 1 - Cross cutting concerns
http://www.codeproject.com/Articles/1045523/Doing-Delegates-Differently-Part

Part 2 - Dynamic Validator
http://www.codeproject.com/Articles/1051860/Doing-Delegates-Differently-Part
Earlier I wrote that I would include an article for actually getting the data from a web site using mechanisms such as WebClient, HttpWebClient etc.

Someone beat me to the punch, go to this well written article in code project. He presents using ScrapySharp. Although I don't have much experience with this product, it looks worth exploring. The article shows how I would use Fidler to examine the requests going back and forth and what needs to be sent as parameters etc.

http://www.codeproject.com/Articles/1041115/Webscraping-with-Csharp

Steve

Using HtmlAgility pack and CssSelectors

To start, I don't claim to be an expert in XPath or Regular Expressions but the following are some observations I have made while parsing HTML documents for client projects.
In the following examples I am using HtmlAgility pack (HAP) to load the HTML into a document object model (DOM) and parse into nodes. Additionaly, there are cases where I have had to parse the document on elements which are not truly nodes such as comments.
In addition to observations about HAP in general, I’ll point out extension methods provided by HAP.CSSSelectors package which allow for much easier selection.
Packages for the example will need to be imported using NuGet. The package descriptions will be loaded in the project but you will need to set NuGet package manager to restore the libraries. In the project I have included a really simple html file with examples of issues I have needed to address in my projects. 
To test without any modifications, you will need to copy the HTML file to the following d…

Codeproject submission

What I really love about consulting is the variety of projects that come my way. Recently I was asked if we could create an application for a client which allowed them to fill in a PDF and store the data in a database. 
I looked around and found several different libraries for dealing with PDF files, I do not mean to say I did an exhaustive search or trial. Almost all these libraries touted their ease of use in creating PDF documents in code, many offered capabilities of reading the documents but almost all of them failed to load a document created with Adobe Acrobat, opening only older unencrypted PDF files. The one exception I found was iTextSharp, a library from http://itextpdf.com/ which offers both a commercial version with iText support provided and an open source version available with a copy left AGPL license.
Read more at  http://www.codeproject.com/Articles/1032782/Reading-Acrofields-from-PDF-files

This project explains how to read PDF form fields from a PDF document

www.Pol…