小帮忙请vb.net,xml [英] Little help please vb.net, xml
问题描述
我遇到了问题,我不知道如何解决.如果可以的话,有人可以帮我吗.
我正在尝试编写一个更新按钮
如果您使用的目录如:
,它将起作用
"C:\ Users \ PC \ Desktop \ xampp \ htdocs \ sites \ update \ application \ test \ Settings.xml"
但这不适用于:
"http://localhost/sites/update/application/test/Settings.xml"
I got a problem and i dont know how to solve it. if you can, could someone please help me with this one.
i am trying to write an update Button
it works if u use a directory like:
"C:\Users\PC\Desktop\xampp\htdocs\sites\update\application\test\Settings.xml"
But it wont work for:
"http://localhost/sites/update/application/test/Settings.xml"
Dim fs As FileStream
Try
fs = New FileStream("http://localhost/sites/update/application/test/Settings.xml", FileMode.Open, FileAccess.ReadWrite) '' Got an error "Error: URI formats are not supported."
''fs = New FileStream("http://io.web44.net//Settings.xml", FileMode.Open, FileAccess.ReadWrite) '' Got an error "Error: URI formats are not supported."
''fs = New FileStream("C:\Users\PC\Desktop\xampp\htdocs\sites\update\application\test\Settings.xml", FileMode.Open, FileAccess.Read) '' Works
MessageBox.Show("Success!")
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
MessageBox.Show("Closing Testing Application.")
End ''TODO: Remove This After Testing!
如您所见,我已经在本地主机和没有运气的在线服务器上尝试过此操作.
我认为这与FileStream有关,有在线吗?
只要问您是否需要更多详细信息即可.
我已经构建了另一个代码块,并且可以工作,但是它使用的是.txt文件而不是.xml文件.
As you can see, i have tried this on my localhost and on an online server with no luck.
i think it has something to do with FileStream, is there an online one?
Just ask if you would like more details.
i have built one other code block and it works, but it uses a .txt file not an .xml file
推荐答案
为什么将URL视为文件?不是吗?您应该先下载文件,然后才能读取文件.但这根本没有意义,因为XML数据应该由XML解析器之一立即读取和解析.我无法解释为什么当XML解析器随时可用并与标准.NET库捆绑在一起时,为什么您甚至尝试手动使用XML资源.
这是我对XML解析可用方法的概述:
Why do you consider URL as a file? It is not, is it? You should download a file first, and only then you can read it. But it makes no sense at all, as XML data should be read and parsed at once by one of XML parser. I cannot explain why you even try to work with an XML resource manually when XML parsers are readily available and bundled with standard .NET libraries.
Here is my overview of available approaches to XML parsing:
- 使用
System.Xml.XmlDocument
类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
请参见- 使用类
].System.Xml.XmlTextReader
; library/system.xml.xmldocument.aspx"target =" _ blank"title =" New Window> ^ - 使用类
- 使用类
System.Xml.XmlTextReader
;这是最快的读取方法,尤其是您需要跳过一些数据.
请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the class
System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that ofXmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
这篇关于小帮忙请vb.net,xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!