Link to home
Start Free TrialLog in
Avatar of janineo
janineoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

XMLDocument or XMLReader?

Hi,

I have an XML file which contains 'meta data' for my application such as values for combo boxes, etc.

It's structure is like this:

<MetaData>
   <ComboValues1>
      <ComboValue1>value1</ComboValue1>
      <ComboValue1>value2</ComboValue1>
      <ComboValue1>value3</ComboValue1>
      <ComboValue1>value4</ComboValue1>
   </ComboValues1>
   <ComboValues2>
      <ComboValue2>value1</ComboValue2>
      <ComboValue2>value2</ComboValue2>
      <ComboValue2>value3</ComboValue2>
      <ComboValue2>value4</ComboValue2>
   </ComboValues2>
   <ComboValues3>
      <ComboValue3 attr1="1" attr2 = "a">value1</ComboValue3>
      <ComboValue3 attr1="2" attr2 = "b">value2</ComboValue3>
      <ComboValue3 attr1="3" attr2 = "c">value3</ComboValue3>
      <ComboValue3 attr1="4" attr2 = "d">value4</ComboValue3>
   </ComboValues3>
.....
</MetaData>

The structure never goes any deeper than that,and as you can see there are attributes with some of the nodes.

This data is used all over in my application, and at the moment I am loading this file into a global XMLDocument at startup and using XPath values to retrieve the data when it's needed.

What I would like to know is if using an XMLReader would be better in terms of speed.
Most combo boxes are populated when the form they are on is loaded, but some are populated dynamically in response to user input.

Any input regarding this would be great, and if anyone could offer some guidelines about when XMLDocument or XMLReader is best to use.

Thanks,
Janine
ASKER CERTIFIED SOLUTION
Avatar of tpwells
tpwells

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janineo

ASKER

Thanks for explaining it to me.
I had found web sites extolling the virtues of XMLReader and was wondering if I had chosen the wrong method!
Your explanation clears it up.

Cheers,
Janine