Groups | Blog | Home
all groups > dotnet xml > september 2006 >

dotnet xml : XPath peformance vs Hash


Ben
9/26/2006 8:42:54 AM
How does XPath performance compare to accessing a Hashtable structure?
I will need to access the same data repeatedly throughout the lifecycle
of my application. What factors should I take into consideration?
Zafar Abbas
9/26/2006 3:53:58 PM
Where do you have your data stored? Are you trying to trade off between
storing it in XML and query using XPath vs storing it using a HashTable in
code? Hasttable is going to give you better performance, but is not going to
be very flexible. Given you have the same data always, Hashtable is the
better approach though.


[quoted text, click to view]

Ben
9/28/2006 8:34:21 AM

The data is already stored in XML. I'm just seeing if I can improve
performance by reading the constant XML data into a HashTable at
startup. The XML Document still resides in memory so I would not be
doing I/O for each document query with XPath.
Ben
9/28/2006 12:05:59 PM

The Program uses data that will always be stored in xml. I'm weighing
the advantage of reading that data into datas structures like a
Hashtable on startup versus just using Xpath to query the xml document
loaded in memory.

Either way I have to read the XML file to retrieve the data. I'm just
wondering how expensive it would be to use xpath to look up the data or
the Hashtable. I will use this data over and over in my application and
the data is constant.

Hashtable is way to go, right?


[quoted text, click to view]
olrt
9/28/2006 4:03:15 PM
Ben a =E9crit :

[quoted text, click to view]

XML is just a way to exchange data with another AppDomain.
What you could do is design a class to maintain your data and
XmlSerialize it when you want to exchange data.

Collection-type attributes are supported by XML serialization.


In pseudo-code you would design a class like this :
class MyData
{
protected Hashtable m_Items;

public MyData()
{
m_Items=3Dnew Hashtable();
}

public Items[] Items
{
get
{
fill Array from m_Items (maybe you can cache the result
for better performance)
}
set
{
fill m_Items from Array (maybe you can cache the result
for better performance)
}
}
}


Regards.
Istvan Loerincz
10/3/2006 1:17:00 AM
I have also a xml file, which I read in, and have to work with the data
in the program and don't change it. (til yet).

I decided to use Hashtables, with (string, XmlNode)

the key is : node.SingleNode(...).InnerText;
the value: node

So I can identify the node by a node specific string, and have access to
the XmlNode istself.

I first wanted ArrayLists, but I wasn't a good idea.
Another possibility to read in the data in Datasets, I dropped this too
(why should I create relational data..., my flexibility is then gone).


So taking Hashtables is a good idea. I didn't find a better idea yet.

Best Regards,
Istvan

AddThis Social Bookmark Button