janineo
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</Combo Value1>
<ComboValue1>value2</Combo Value1>
<ComboValue1>value3</Combo Value1>
<ComboValue1>value4</Combo Value1>
</ComboValues1>
<ComboValues2>
<ComboValue2>value1</Combo Value2>
<ComboValue2>value2</Combo Value2>
<ComboValue2>value3</Combo Value2>
<ComboValue2>value4</Combo Value2>
</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
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</Combo
<ComboValue1>value2</Combo
<ComboValue1>value3</Combo
<ComboValue1>value4</Combo
</ComboValues1>
<ComboValues2>
<ComboValue2>value1</Combo
<ComboValue2>value2</Combo
<ComboValue2>value3</Combo
<ComboValue2>value4</Combo
</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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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