Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

URI Format not supported

I need some help edit a simple tool, that read a xml file from local pc.
I need to make it able to read xml from web instead of local pc, until I get error.
Can anyone give me an hint if I send project?
[Image: giphy.gif]
(Oct 28, 2017 11:37 AM)aGFjaw-- Wrote:  I need some help edit a simple tool, that read a xml file from local pc.
I need to make it able to read xml from web instead of local pc, until I get error.
Can anyone give me an hint if I send project?

uri class in .net works only if http://, https:// or file:// is used on the beginning of an address.
Sure, but there should be an error somewhere.

Little screenshoot under spoiler.

Spoiler (Click to View)
[Image: giphy.gif]
(Oct 28, 2017 11:37 AM)aGFjaw-- Wrote:  I need some help edit a simple tool, that read a xml file from local pc.
I need to make it able to read xml from web instead of local pc, until I get error.
Can anyone give me an hint if I send project?

Can you share that link of that xml web or any code ?? 😅 😅 😅
If I an not mistaken, you will need to create a stream that fetches the XML file from a specific URL.

Example Code:
Code
Dim URLString As [String] = " http://localhost/books.xml"
Dim reader As New XmlTextReader(URLString)
(Oct 28, 2017 01:37 PM)aGFjaw-- Wrote:  Sure, but there should be an error somewhere.

Little screenshoot under spoiler.

Spoiler (Click to View)

Maybe because you have an empty variable?
On your button mnuOpen, you need to browse first for nothing before the variable "Filename" get the data.
Here is full code.

Code
Imports System.Xml
Imports System.Text
Imports System.IO

Public Class MainForm
  Dim mFileName As String = String.Empty
  Dim mDocument As XmlDocument = Nothing

Private Sub mnuOpen_Click(sender As System.Object, e As System.EventArgs) Handles mnuOpen.Click
  If OpenDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
            'FileName = OpenDialog.FileName
            FileName = "http://vb.net-informations.com/xml/img/product.xml"
            LoadFile()
  End If
End Sub

Private Sub LoadFile()
  If mDocument Is Nothing Then
    mDocument = New XmlDocument
  End If

  Dim Content As String = File.ReadAllText(FileName, Encoding.Default)
  mDocument.LoadXml(Content)
  rtbXmlSource.Text = Content
  trvNodes.Nodes.Clear()
  FillTreeView(trvNodes.Nodes, mDocument.DocumentElement)
End Sub

Private Sub FillTreeView(TreeNodes As TreeNodeCollection, Xml_Node As XmlNode)
  Dim NewNode = TreeNodes.Add(Xml_Node.Name)
  NewNode.Tag = Xml_Node

  For Each Node As XmlNode In Xml_Node.ChildNodes
    FillTreeView(NewNode.Nodes, Node)
  Next
  trvNodes.ExpandAll()
End Sub

Private Property FileName As String
  Get
    Return mFileName
  End Get
  Set(value As String)
    lblFileName.Text = value
    mFileName = value
  End Set
End Property

Private Sub trvNodes_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles trvNodes.AfterSelect
  If trvNodes.SelectedNode IsNot Nothing Then
    PropertyGrid1.SelectedObject = trvNodes.SelectedNode.Tag
  End If
End Sub
End Class
[Image: giphy.gif]
Its a good idea to download that file in Temp folder and then read it from XmlReader and on

OnFormClosingEvent delete that xml file from Temp directory.
Yes, I thought to do so, but I would like to read it directly from the web.
[Image: giphy.gif]
if you can share that link then i will create and upload the project.
Sure :

Download

Scan
[Image: giphy.gif]
Thanks for releasing it to us
You would replace the OpenFileDialog code with the code I provided up top. You need to create a stream that requests/reads the file from a specific URL.
Already tried but it does not work.
I also tried with WebClient.
There should be more stuffs to edit, something I don't understand.
[Image: giphy.gif]
(Oct 29, 2017 11:34 AM)aGFjaw-- Wrote:  Already tried but it does not work.
I also tried with WebClient.
There should be more stuffs to edit, something I don't understand.

What does your current code look like? I looked at the last code you posted, and it seems like you are still using OpenFileDialog.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by greekdevSep 9, 2026 10:36 AM 2 126 Sep 9, 2026 10:36 AM
Last Post: greekdev
[Shell] by TimanxdDec 13, 2018 02:32 AM 7 292 Dec 13, 2018 02:32 AM
Last Post: Bobbyx28
[Python] by GrunclePug69Dec 20, 2016 02:52 PM 3 370 Dec 20, 2016 02:52 PM
Last Post: Goodies