S
suzy
Hello,
If I have some XML in the following format:
<Foods>
<Food Name="Pizza">
<Ingredient Amount="500g">Flour</Ingredient>
<Ingredient Amount="100g">Cheese</Ingredient>
</Food>
<Food Name="Pasta">
<Ingredient Amount="500g">Pasta</Ingredient>
<Ingredient Amount="50g">Tomato Puree</Ingredient>
</Food>
</Foods>
I want to search the XML doc for a certain type of "Food", then read the
ingredient values for that type of food. I do not need to write/amend the
XML doc. What is the best/efficient way to do this?
If I was using normal XML I would have just loaded the XML into a
DomDocument and used XPath to find the node, assign it to a node object then
use .SelectSingleNode, etc. But I have read that using an DomDocument
object in c# is inefficient if you are just reading (and not writing) XML.
Any example or links would be appreciated.
Thanks.
If I have some XML in the following format:
<Foods>
<Food Name="Pizza">
<Ingredient Amount="500g">Flour</Ingredient>
<Ingredient Amount="100g">Cheese</Ingredient>
</Food>
<Food Name="Pasta">
<Ingredient Amount="500g">Pasta</Ingredient>
<Ingredient Amount="50g">Tomato Puree</Ingredient>
</Food>
</Foods>
I want to search the XML doc for a certain type of "Food", then read the
ingredient values for that type of food. I do not need to write/amend the
XML doc. What is the best/efficient way to do this?
If I was using normal XML I would have just loaded the XML into a
DomDocument and used XPath to find the node, assign it to a node object then
use .SelectSingleNode, etc. But I have read that using an DomDocument
object in c# is inefficient if you are just reading (and not writing) XML.
Any example or links would be appreciated.
Thanks.