Alex Rivera | Logout

XPath vs DeSerialization: which one is better in performance for read operations

Asked 2008-11-10T11:59:55.917
10

I'm passing small (2-10 KB)XML documents as input to a WCF service. now I've two option to read data values from incoming XML

  1. Deserialize to a strongly typed object and use object properties to access values
  2. use XPath to access values

which approach is faster? some statistics to support your answer would be great.

Edit
Report

1 Answer

4

There's a third option of sticking with XML, but query with whatever XML API you're using - e.g. LINQ to XML makes queries relatively straightforward in code.

Have you already parsed the text into an XML document?

Are you convinced that this is actually a significant performance bottleneck in your code? (e.g. if you're then talking to a database, then don't worry about this to start with - just get it to work in the simplest way first)

Are the queries always the same, or are they dynamic in some way?

Do you have a test rig with realistic messages and queries? If not, you need one in order to evaluate any answers given here with your data. If you do, I would expect it to be reasonably easy to try it yourself :)

answered 2008-11-10T12:04:25.657

Your Answer