Hi,
.Net 2.0 Framework
Windows XP
I am creating an XML file for transport, the creation process works fine. However the import of the file is acting strange. The XML File is in written in the following format:
When I loop through the XML document I can only get the Element and the first Element String. The second Element String comes back with a NodeType of Text. It makes sense that the NodeType for the second Element would be Element???
Code
Export (Create XML File)
Import (Read XML File)
Could someone please explain to me why this is happening?
Thanks in advance,
Jay
.Net 2.0 Framework
Windows XP
I am creating an XML file for transport, the creation process works fine. However the import of the file is acting strange. The XML File is in written in the following format:
HTML:
<Task Name="Add Student" Description="Add a new Student">
<TaskLink>Search Student</TaskLink>
<TaskLink>View Student</TaskLink>
</Task>
When I loop through the XML document I can only get the Element and the first Element String. The second Element String comes back with a NodeType of Text. It makes sense that the NodeType for the second Element would be Element???
Code
Export (Create XML File)
VB.NET:
Dim ws As New XmlWriterSettings()
ws.CheckCharacters = True
ws.CloseOutput = True
Using xw As XmlWriter = XmlWriter.Create("c:\Test1.xml", ws)
Try
xw.WriteStartDocument(True)
xw.WriteComment("AzMan Export Created at " & DateTime.Now.ToString("hh:mm:ss"))
'Write Application Element
xw.WriteStartElement("Task")
xw.WriteAttributeString("Name", "Add Student")
xw.WriteAttributeString("Description", "Add a new Student")
xw.WriteElementString("TaskLink", "Search Student")
xw.WriteElementString("TaskLink", "View Student")
xw.WriteEndElement()
xw.WriteEndDocument()
xw.Close()
MsgBox("Export Complete", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
Catch ex As Exception
MsgBox("Export Failed" & vbCrLf & ex.Message, MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
End Try
End Using
VB.NET:
Dim xr As New XmlTextReader("C:\Test1.xml")
Try
While xr.Read
Select Case xr.NodeType
Case XmlNodeType.Element
If xr.Name = "Task" Then
MsgBox("Task - " & xr.GetAttribute("Name") & " - " & xr.GetAttribute("Description"))
End If
If xr.Name = "TaskLink" Then
MsgBox("Task Link - " & xr.ReadElementString)
End If
Case XmlNodeType.Text
MsgBox("Opps?")
End Select
End While
xr.Close()
MsgBox("Import Complete", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
Catch ex As Exception
MsgBox("Import Failed" & vbCrLf & ex.Message, MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
End Try
Thanks in advance,
Jay
Last edited by a moderator: