Click here to Skip to main content
11,641,209 members (65,435 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET XmlReader
I am just starting with XMLTextReader so apologies if the answer is obvious.

I am trying to extract attributes from an XML file, which appears to have the same element name wrapped within itself. This extract shows the problem:
<osgb:heightabovedatum xmlns:osgb="#unknown">
It reads the first "osgb:heightAboveDatum" which has no value, but then appears to skip the second line and so misses the value there. It reads the next line "osgb:accuracyOfHeightAboveDatum" OK presumably because it has a different element?

Any help appreciated!

The above XML didn't format correctly - it should be:


I'm using XMLTextReader to get the data from each element and this is the code for the heightAboveDatum element:

If GMLReader.Name.ToString = "osgb:HeightAboveDatum" And GMLReader.NodeType <> XmlNodeType.EndElement Then
heightAboveDatum = Trim(GMLReader.ReadString())
End If

It's returning an empty string as I presume it's not reading the child node containing the data value.
Posted 14-Sep-12 9:06am
Edited 16-Sep-12 23:55pm
Zoltán Zörgő at 14-Sep-12 15:28pm
The xml snippet you have tried to post is missing!
Sergey Alexandrovich Kryukov at 14-Sep-12 16:07pm
If looks like you forgot to escape HTML entities, which you could do using "encode" item on top of edit control, that's why the garbage at the end.

And normally, nothing skips. You could screw up things in your code. How about a code sample?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 185
4 Afzaal Ahmad Zeeshan 129
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 185
4 Afzaal Ahmad Zeeshan 129

Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100