-2

I have an xml on this url. I need to read this xml. I can not store this file and read the data because this xml refreshes after perticular interval.

How can I read this file in c#?

1 Answers1

0

I can not store this file and read the data because this xml refreshes

That is incorrect. You do want to read the file as it's presented at a given moment in time. If it's updated the second after that, you need to read it again.

Anyway see Read xml from URL to read it from URL, How to load XML from URL on XmlDocument() and so on: the XML APIs offer options to load XML from an URL.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • Thank you for your response. But my xml file gets downloaded when you hit the xml path in browser. So it does not get read from xmlReader. It is not like http://api.wunderground.com/api/your_key/conditions/q/92135.xml this url. In this url the XML gets generated on browser. But if I enter my XML it gets downloaded in browser as a physical file – user2130929 Jun 02 '15 at 12:11
  • 1
    I don't know what that means or what you're trying to say with that. – CodeCaster Jun 02 '15 at 12:12
  • Reading a remote file means downloading it. XMLReader will download and read the XML contents pointed by the URL just fine. If you have a specific problem, please post the full error details and the code that produced it – Panagiotis Kanavos Jun 02 '15 at 12:15
  • download string and add to either XmlDocument or XDocument. XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(string); XDocument doc2 = XDocument.Parse(string); – jdweng Jun 02 '15 at 12:16
  • 1
    @jdweng why? This is no different than calling `doc1.Load()` – Panagiotis Kanavos Jun 02 '15 at 12:17
  • var m_strFilePath = "https://vimeo.com/api/v2/album/2307466/videos.xml"; string xmlStr; using (var wc = new WebClient()) { xmlStr = wc.DownloadString(m_strFilePath); } var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlStr); I am getting remote connection error in this case. That means it does not get XML file to read properly – user2130929 Jun 02 '15 at 12:29
  • You want to make sure all the data is received (and flushed) before processing the xml document. Using a Reader is fine, but make sure the check is done that ALL the data is received. – jdweng Jun 02 '15 at 13:48
  • If you are getting connection errors, there may be a virus checker or firewall that is blocking the contents of the data. – jdweng Jun 02 '15 at 13:50