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!

  • Unsure what you're asking - is [this](http://stackoverflow.com/q/18607381/304683) what you're looking for? – EdSF Jan 17 '17 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. – user2653814 Jan 19 '17 at 03:06
  • If you want to send XML data somewhere [here's a _general idea_](http://stackoverflow.com/a/17535912/304683) (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](http://stackoverflow.com/a/17396739/304683). There are other ways like [`XDocument`](http://stackoverflow.com/a/7798894/304683), [`XMLReader`](https://msdn.microsoft.com/en-us/library/system.xml.xmlreader(v=vs.110).aspx), so look those up as well. Hth. – EdSF Jan 19 '17 at 04:38

0 Answers0