3

If I use

xmlCommand.ReadToFollowing("A")
valueA = xmlCommand.ReadElementContentAsString

xmlCommand.ReadToFollowing("B")
valueB = xmlCommand.ReadElementContentAsString

If there is no Element A then I get a

The ReadElementContentAsString method is not supported on node type None. Line 0, position 0

Which makes sense, since it didn't find it

the ReadToFollowing returns a boolean whether it found the element or not, so I could check before I try to assign a value, but it looks like the reader reads all the way to the end looking for it and I still want to get value B even if A is not there. Is there some way to reset the reader to read from the beginning, or should I ditch XmlReader altogether?

mellerbeck
  • 199
  • 2
  • 14

1 Answers1

1

I believe XMLReader is forward-only which means you cannot rewind back to beginning.

In your case you are probably going to need to create a new instance of XmlReader and go through it again. Not sure if that is the answer you were looking for :P

cush
  • 283
  • 2
  • 8