XPath accessing a non-uniform XML file

code4arab

New Member
I have an XML file that's modeled something like the following:\[code\]<data> <customer> <id></id> <name></name> <model> <id></id> <name></name> <item> <id></id> <history> <date></date> <location></location> </history> </item> <item> <id></id> <history> <date></date> <location></location> </history> </item> </model> <model> <id></id> <name></name> <item> <id></id> <history> <date></date> <location></location> </history> </item> </model> </customer> <customer> <id></id> <name></name> <model> <id></id> <name></name> <item> <id></id> <history> <date></date> <location></location> </history> </item> <item> <id></id> <history> <date></date> <location></location> </history> </item> </model> </customer> <customer> <id></id> <name></name> </customer></data>\[/code\]Using XPath in C#, I need to access the following for each customer:\[code\]customer/idcustomer/namecustomer/model/idcustomer/model/namecustomer/model/item/idcustomer/model/item/history/datecustomer/model/item/history/location\[/code\]When data does not exist for any given customer, then the result stored will be null, since all fields of my customer object must be populated. If the XML file was uniform, this would be easy. My problem is accessing each customer's data when each customer may potentially have a different number of model and item nodes. Any ideas?
 
Back
Top