-4

I am stuck at a place while working with a Windows Application.

I have to extract information from an XML file by logging on to a particular url with known credentials, where my XML file is present.

I am unable to get how to access the real time information from web for a Windows Application?

Matthias R.
  • 441
  • 2
  • 15
Rocky
  • 3
  • 6
  • can u give the link? – Val Nolav Aug 12 '14 at 10:01
  • 3
    You have to be a bit more specific, don't you think? What application are you talking about? What did you try? Did it fail? Did you get error messages? Why did you not post your code? – Mathias Müller Aug 12 '14 at 10:03
  • string xml = new WebClient().DownloadString(url); after getting string xml, you can do manipulations you want – Val Nolav Aug 12 '14 at 10:04
  • Sorry,I can't give the link. I do have the administrator privileges for logging in but how to do it via code. @ValNolav – Rocky Aug 12 '14 at 10:04
  • 1
    what is the question? can you download the xml file from url? or can you login successfully to the website or not? or deserialization of XML is the problem ? – Val Nolav Aug 12 '14 at 10:06
  • i assume that by "logging on" you mean that you have some credentials you have to add to your request to reach the xml file - to do so have a look [here](http://msdn.microsoft.com/en-us/library/system.net.webclient.credentials%28v=vs.110%29.aspx) for further reading how to work with credentials on requests. – Matthias R. Aug 12 '14 at 10:08
  • @ValNolav Thankyou.It served the purpose. – Rocky Aug 12 '14 at 10:09
  • @Matt Exactly Matt,this is what I meant.I have username & password to login to web page where i can find XML file.Now I have to extract child nodes attribute information from that XML file on basis of which I have to send E-mail notifications. – Rocky Aug 12 '14 at 10:12

2 Answers2

0

according to the comments section, your path of success would look like this:

  1. make yourself familiar with the WebClient class (as we already told you) by having a look at this website
  2. get to know how to convert the result from the web client into a so called XmlDocument (you can do a further reading on this SO question and answers) or have a look at the msdn developer network for some examples like this
  3. put it all together, clap your hands three times and integrate the module into your existing project

in general: the msdn developer network gives you a nice basic idea of how things work in .NET as well as searching on SO for related questions. and for the next time: provide some code snippets or the core functions of "what's not working" so we can easily get a feeling of what you already tried or what might be gone wrong so far.

Community
  • 1
  • 1
Matthias R.
  • 441
  • 2
  • 15
-1

You can download XML data from URL using WebClient class. Then load it into XDocument.

Also XDocument has Load method for direct XML loading by URI.

var doc = XDocument.Load("http://stackoverflow.com/feeds/question/25261435");
Der_Meister
  • 4,771
  • 2
  • 46
  • 53