I am overriding a method which has an XmlReader being passed in, I need to find a specific element, add an attribute and then either create a new XmlReader or just replace t
You can't easily do this with XmlReader
- at least, not without reading the whole XML document in from the reader, futzing with it and then creating a new XmlReader
from the result. That defeats a lot of the point of using XmlReader
though - namely the ability to stream large documents.
You could potentially derive from XmlReader
, forwarding most method calls to the existing reader but intercepting them where appropriate to add extra attributes etc... but I suspect that code would be really quite complex and fragile.