Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i hava a page for regester customer the contains name ,activity an location ,

but location contain part,city the save in XML file and now most display in XML file in page but

i dont know

1- how read location from XML file ( only Part or Only City of part)?

2-how display location in Html.DropDownList ?

3-How Combine location with other details in page regester customer?
Posted
Updated 15-Jun-11 18:19pm
v2

1 solution

You did not share how you represent Location and other detail, so you're on your own.
You can use the following approached to parse XML:


  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


Now, do you have to read existing XML with already predefined schema, or you can generate your own? It would be much better. In this case, you should use serialization instead of doing it all on a level of XML.

The best really non-intrusive way to serialize is the Data Contract.

See http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past answers where I argument in favor of this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900