473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

XML Anomaly

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:

<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)



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

Import (Read XML File)


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

Could someone please explain to me why this is happening?

Thanks in advance,

Jay
Dec 18 '06 #1
0 899

Sign in to post your reply or Sign up for a free account.

Similar topics

226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
16
by: clintonG | last post by:
At design-time the application just decides to go boom claiming it can't find a dll. This occurs sporadically. Doing a simple edit in the HTML for example and then viewing the application has...
1
by: mai | last post by:
Hi everyone, i'm trying to exhibit FIFO anomaly(page replacement algorithm),, I searched over 2000 random strings but i couldnt find any anomaly,, am i I doing it right?,, Please help,,,The...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.