473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XPath peformance vs Hash

Ben
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?

Sep 26 '06 #1
5 2281
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.
"Ben" <be***********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
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?

Sep 26 '06 #2
Ben

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.

Sep 28 '06 #3
Ben

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?
Zafar Abbas wrote:
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.
"Ben" <be***********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
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?
Sep 28 '06 #4
Ben a écrit :
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.
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=new 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.

Sep 28 '06 #5
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

*** Sent via Developersdex http://www.developersdex.com ***
Oct 3 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
6
by: Scott Simpson | last post by:
What is a good tool for running XPath queries on Linux? I have the O'Reilly XPath book and I'm using XPath Visualizer on Windows and that seems to work fine, but I'm looking for something on Linux....
5
by: John Bailo | last post by:
I wrote a webservice to output a report file. The fields of the report are formatted based on information in an in-memory XmlDocument. As each row of a SqlDataReader are looped through, a...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.