|
-
Jan 20th, 2004, 01:12 PM
#1
Thread Starter
Member
Problem Parsing XML
I hava problem where my code breaks when it encounters low-ASCII (01-32 decimal) in any node when this is run:
Code:
XDoc = New XmlDocument
If flgrp = 0 Then filepath = RecCasepath & "\Playlists\"_
& filepath
XDoc.Load(filepath)
RCgroup = XDoc.DocumentElement.SelectNodes("//media")
Anything below 20 hex causes an exception. I know where the problem comes from, but I need to catch this as it stems from an older version of the software writing the XML and many people wtill have this error in their XML files..
-
Jan 20th, 2004, 03:08 PM
#2
Sleep mode
VB Code:
Try
XDoc = New XmlDocument
If flgrp = 0 Then filepath = RecCasepath & "\Playlists\"_
& filepath
XDoc.Load(filepath)
RCgroup = XDoc.DocumentElement.SelectNodes("//media")
Catch
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
-
Jan 20th, 2004, 03:17 PM
#3
Thread Starter
Member
I know what that's going to show.. '01hex is an invalid character'
But it will break of parsing the XML file, I woudl like to prevent that if I can..
-
Jan 20th, 2004, 03:21 PM
#4
Sleep mode
Prevent what ? the error or the error handler ?
-
Jan 20th, 2004, 03:32 PM
#5
Thread Starter
Member
I would like to prevent the exception.. Right now my code will skip the file with the problem, but I would like to skip the node with the problem if I can.. but it seems the exception is thrown when
RCgroup = XDoc.DocumentElement.SelectNodes("//media")
is executed, so I do not know if I can (I am guessing I cannot using this method..)
-
Jan 20th, 2004, 03:40 PM
#6
Sleep mode
1-
Try this ,
VB Code:
On Error Resume Next
XDoc = New XmlDocument
If flgrp = 0 Then filepath = RecCasepath & "\Playlists\"_
& filepath
XDoc.Load(filepath)
RCgroup = XDoc.DocumentElement.SelectNodes("//media")
2-
and you can handle the exception but don't need to show it in a messagebox . This will continue your program execution flow .
-
Jan 20th, 2004, 05:04 PM
#7
Thread Starter
Member
That will prevent the exception, but still skip the erroneous file.. I prefer to be able to tell what went wrong so I have an excuse..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|