Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read an XML file from http address

I need to read an xml file using c#/.net from a source like so: https://10.1.12.15/xmldata?item=all

That is basically just an xml file.

StreamReader does not like that.

What's the best way to read the contents of that link?

The file looks like so:

- <RIMP>
     - <HSI>
       <SBSN>CZ325000123</SBSN> 
       <SPN>ProLiant DL380p Gen8</SPN> 
       <UUID>BBBBBBGGGGHHHJJJJ</UUID> 
       <SP>1</SP> 
       <cUUID>0000-000-222-22222-333333333333</cUUID> 
- <VIRTUAL>...
like image 216
sd_dracula Avatar asked Jan 04 '13 16:01

sd_dracula


People also ask

How do I retrieve an XML file from a URL?

Navigate to 'File > New > EasyCatalog Panel > New XML Data Source'; this will open up the 'Data Source Configuration' dialog. In this dialog there will be a drop down next to 'Source:' that is set to 'File' by default.

How do I view an XML file on a website?

View an XML file in a browser If all you need to do is view the data in an XML file, you're in luck. Just about every browser can open an XML file. In Chrome, just open a new tab and drag the XML file over. Alternatively, right click on the XML file and hover over "Open with" then click "Chrome".

How do I read an XML readable file?

XML files are encoded in plaintext, so you can open them in any text editor and be able to clearly read it. Right-click the XML file and select "Open With." This will display a list of programs to open the file in. Select "Notepad" (Windows) or "TextEdit" (Mac).


1 Answers

You'll want to use LINQ to XML to process the XML file. The XDocument.Load Method supports loading an XML document from an URI:

var document = XDocument.Load("https://10.1.12.15/xmldata?item=all");
like image 177
dtb Avatar answered Sep 23 '22 10:09

dtb