I figured out the problem:
MainListWriter.WriteStartElement("Main List")
("Main List") has a space there, once I changed this to ("MainList"), the problem went away.
Can you not have spaces as a name? Is there a way to do this?
thanks
Gerry
Hi all,
When I try to read the XML I get the error below and highlights this
(Do While MainReader.Read)?
Error:
A first chance exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
Please help.
Friend Function CreateXMLfiles()
'Write XML DEFAULT files
Dim MainListWriter As XmlTextWriter = New XmlTextWriter(WorkingDir & "main.xml", System.Text.Encoding.UTF8)
MainListWriter.Formatting = Formatting.Indented
MainListWriter.Indentation = 2 'Indent tags by 2 characters.
MainListWriter.QuoteChar = """"c 'Enclose attributes' values in double quotes.
MainListWriter.WriteStartDocument(True)
MainListWriter.WriteComment("Main List Build")
MainListWriter.WriteStartElement("Main List")
MainListWriter.WriteStartElement("MAIN")
MainListWriter.WriteAttributeString("Name", "Administration")
MainListWriter.WriteElementString("sublist", "")
MainListWriter.WriteEndElement()
MainListWriter.WriteStartElement("MAIN")
MainListWriter.WriteAttributeString("Name", "Search")
MainListWriter.WriteElementString("sublist", "")
MainListWriter.WriteEndElement()
MainListWriter.WriteStartElement("MAIN")
MainListWriter.WriteAttributeString("Name", "----------------------")
MainListWriter.WriteEndElement()
MainListWriter.WriteStartElement("MAIN")
MainListWriter.WriteAttributeString("Name", "ERCP")
MainListWriter.WriteElementString("sublist", "4")
MainListWriter.WriteEndElement()
MainListWriter.WriteEndDocument()
MainListWriter.Close()
End Function
Friend Function LoadList(ByVal ElemName As String)
Dim MainReader As New XmlTextReader(WorkingDir & "main.xml")
Do While MainReader.Read
Select Case MainReader.NodeType
Case XmlNodeType.Document ' The node is an Element
Case XmlNodeType.Element
End Select
Loop
MainReader.Close()
End Function
Thanks
Gerry
Kevin Yu [MSFT] - 29 Oct 2003 02:45 GMT
Hi Gerry,
The XML tag cannot contain spaces in the tag name. Because if there's a
space in it, the parser will consider the following part of the space as an
attribute.
Kevin Yu

Signature
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| From: "Gerry Viator" <viatorg@musc.edu>
| References: <ORRJShWnDHA.3256@tk2msftngp13.phx.gbl>
[quoted text clipped - 48 lines]
| MainListWriter.WriteStartElement("MAIN")
| MainListWriter.WriteAttributeString("Name",
"----------------------")
| MainListWriter.WriteEndElement()
| MainListWriter.WriteStartElement("MAIN")
[quoted text clipped - 17 lines]
| Thanks
| Gerry
Gerry Viator - 29 Oct 2003 13:51 GMT
Thanks
Gerry
> Hi Gerry,
>
[quoted text clipped - 88 lines]
> | Thanks
> | Gerry