-
Problems Reading XML
I'm having problems. When I try to load an XML node that contains a space, it gives me an error saying Text is not a valid XMLNodeType.
Here's my code:
Code:
Dim strFileName As String
strFileName = Application.StartupPath + "\Templates\" + fi.Name
Dim m_xmlr As XmlTextReader
m_xmlr = New XmlTextReader(Application.StartupPath + "\Templates\" + fi.Name)
m_xmlr.WhitespaceHandling = WhitespaceHandling.None
Try
m_xmlr.Read()
m_xmlr.Read()
Catch
MsgBox("Could not load template " + fi.Name + ": Invalid template file!", MsgBoxStyle.Critical, "Error")
End Try
While Not m_xmlr.EOF
Try
m_xmlr.Read()
Catch
MsgBox("Could not load template " + fi.Name + ": Invalid template file!", MsgBoxStyle.Critical, "Error")
End Try
If Not m_xmlr.IsStartElement() Then
Exit While
End If
Try
m_xmlr.Read()
Catch
MsgBox("Could not load template " + fi.Name + ": Invalid template file!", MsgBoxStyle.Critical, "Error")
End Try
MsgBox(m_xmlr.ReadElementString("templateName"))
Try
templateName = m_xmlr.ReadElementString("templateName")
templatedescription = m_xmlr.ReadElementString("templateDescription")
templatedirectory = m_xmlr.ReadElementString("templateDirectory")
templateicon = m_xmlr.ReadElementString("templateIcon")
Catch
MsgBox("Could not load template " + fi.Name + ": Invalid template file!", MsgBoxStyle.Critical, "Error")
End Try
Any ideas?