Gautam Gautam - 20 days ago 4
Vb.net Question

What is the best way to read an XML file from Embedded resources?

Dim xmldoc As New XmlDocument()
Dim xmlnode As XmlNodeList
Dim i As Integer
Dim str As String

xmldoc.LoadXml("countyByRegion.xml")


This throws


An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but was not handled in user code. Additional information: Data at the root level is invalid. Line 1, position 1.

Answer

I would normally do this

Dim fsXML As New FileStream("countyByRegion.xml", FileMode.Open, FileAccess.Read)

And then use xmldoc.Load(fsXML)