0

I have several methods that are able to successfully post predetermined string values to a separate web application, but I am stuck on how to capture and post data from an xml file.

I have a view that returns a file path to one of my controllers, but am stuck on how to get that data to my api controller. I can read the xml data into an XmlDocument as shown below, but from what I can tell, xmldocuments are not serializable.

XmlDocument doc = new XmlDocument();
doc.Load(@"dummyfilepath/" + FileName);

How can I get this xml data into my api controller to pass it as a parameter?

thanks!

3
  • Unsure what you're asking - is this what you're looking for? Commented Jan 17, 2017 at 22:52
  • thanks, sorry for the confusion. i am stuck on how I can get data from an xml file on my computer into a variable in my web api that I can send as a parameter to an external web application. Likely just a few lines of simple syntax I'm not familiar with yet, but having trouble locating. Commented Jan 19, 2017 at 3:06
  • If you want to send XML data somewhere here's a general idea (you can probably use HttpClient if you want). If you mean you want to extract data from XML first and create some other object before sending it somewhere, you'll have to parse it - here's an example using XMLDocument. There are other ways like XDocument, XMLReader, so look those up as well. Hth. Commented Jan 19, 2017 at 4:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.