Exception's data, numeric values shown as 0
Exception's data, numeric values shown as 0
(OP)
Colleagues,
Here's the code:
These two numerics, line number and line position always displayed as zero.

What am I doing wrong?
TIA!
Here's the code:
CODE --> .NET
Try Do While loXMLReader.Read() ' some code Loop 'While loXMLReader.Read() Catch loErr As XmlException MsgBox("Error on line #" & loErr.LineNumber.ToString() & ", pos. #" & loErr.LinePosition.ToString() & vbCrLf & "occurred:" & _ vbCrLf & loErr.Message & vbCrLf & "when reading file" & vbCrLf & loErr.SourceUri) llGoOn = False End Try
These two numerics, line number and line position always displayed as zero.

What am I doing wrong?
TIA!
Regards,
Ilya
RE: Exception's data, numeric values shown as 0
RE: Exception's data, numeric values shown as 0
CODE --> .NET
Regards,
Ilya
RE: Exception's data, numeric values shown as 0
RE: Exception's data, numeric values shown as 0
T's a real, "live" data. I could've "obfuscate" it, but methinks it's not worth the effort.
The question was (and is): why XmlException shows line and position number as Zeros.
So, lemme dig down deeper:
What is that line and position numbers that XmlException is suppose to show, line and position in the program, or line and position in the read XML file?
(The description on the page https://docs.microsoft.com/en-us/dotnet/api/system... is "kinda" brief,
and https://stackoverflow.com/questions/621059/current... is kinda foggy for this illiterate one...)
TIA!
Regards,
Ilya
RE: Exception's data, numeric values shown as 0
Look what I've found!
When I changed (see the post #2, from me, on 20 Mar 2020 @ 13:25 - not sure about the time stamp) the .ConformanceLevel = ConformanceLevel.Auto to .ConformanceLevel = ConformanceLevel.Fragment
I got totally different error message (this time with non-zero numerics and with comprehensive text):
Well, live and learn every day!
Now I know how to proceed with this code!
Regards,
Ilya
RE: Exception's data, numeric values shown as 0
CODE
Dim loXMLReader As XmlReader = XmlReader.Create(tcFileIn, loXMLReaderSettings)
But I don't hold out much hope this will fix things; there are a number of error conditions that result in no line or position info being provided, and they (not suprisingly) result from the specific format of the XML being read. For example, the XML file below wu=illl casue your code to throw an exception with Line and Position of 0 - but with a somewhat more descriptive error message concerning the use of DTDs (which can be fixed through the XMLReaderSettings (which, by the way, your code is not applying, as you need to have set the settings before you create the XMLReader ...)
CODE --> XMLfile
RE: Exception's data, numeric values shown as 0
Yes, I have figured it out already, colleague, but thank you anyway. T's already adjusted in my code.
And - yes, ReadElementContentAsString() won't read that node on line 4 coz it does have "children".
Well, it feels like I am to learn using XmlNode.HasChildNodes property!
Well, it's Friday-after-lunch (or TGIF, if you prefer), so - HANW everybody!
Regards,
Ilya
RE: Exception's data, numeric values shown as 0
Yep, hadn't seen your 20:09 post when I wrote mine. Glad you made progress.