Is there a way to upload an xml in c# and map the values to certain textboxes using jquery?
<?xml version="1.0" encoding="ISO-8859-1"?>
<AuditSheet>
<CustomerInfo>
<CustomerName></CustomerName>
<PlantSiteName></PlantSiteName>
<SystemName></SystemName>
<PhysicalAddress1></PhysicalAddress1>
<PhysicalAddress2></PhysicalAddress2>
</CustomerInfo>
</AuditSheet>
youve asked a complex question with very little description of what it is exactly you want to achieve.
What I think you want to do is allow a user to upload an XML file to a webpage and then i guess using AJAX send the XML to the server and have it return JSON so you can use that to populate fields on that same page.
What you can do is create a HTTP handler (implementing IHttpHandler). Register that handler in your web.config with a specific URLfor example /services/sheetuploader.ashx.
Then define a class called AuditSheet and CustomerInfo and decorate them with a DataContract attribute and mark the members matching your AuditSheet XML elements with DataMember attributes.
Something like:
You can then use the System.Runtime.Serialization.DataContractSerializer object to read the XML into an instance of your AuditSheet class. See the ReadObject method for doing that. You do this in the ProcessRequest method of your Http Handler.
After creating the object you can then serialize to JSON by using System.Runtime.Serialization.Json.DataContractJsonSerializer and its WriteObject method.
To send back JSON to the client you add the following to the ProcessRequest method
to send the XML to the server you can use jQuery’s AJAX method using a POST request.
Hope im close to what youre actually trying to do and that this can help you get started.
Yoav.