.NET Gurus? Generating XML doc from ASP.NET form fields
-
Hi, Scenario: - ASP.NET controls having their values to be stored in an XML file (with a predetermined schema) and their values will be loaded from this file as well. - Each control will map to one and only one XML element. Example: <asp:TextBox ID="_carCurrentValue" runat="server"> </asp:TextBox > will be stored in: <?xml version="1.0" encoding="UTF-8"?> <tns:competitiveQuoteRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > ... <risk xsi:type="tns:privateCarRiskType"> ... <vehicle> ... <value>1500</value> ... </vehicle> ... </risk> </tns:competitiveQuoteRequest> My Suggested solution: I have created custom controls to carry their destination path (and other metadata) like: <custom:TextBoxField ID="_carCurrentValue" runat="server" XPath="/risk/vehicle/value" /> And created a procedure that will loop through the controls and generate the XML document from scratch based on the XPath in the controls. Smarter solution anyone? I did not use any XML library to generate the XML document, is there any solution that can read from XPath (for example) and generate the node in the XML file? Suggestions?
Make it simple, as simple as possible, but not simpler. AdamTibi.NET