473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XmlTextReader-derived class - overrides not being called

I have a class derived from XmlTextReader. It implements the following
methods:
public override void ReadEndElement()
public override void ReadStartElement()
public override string ReadString()
public override bool Read()

When the class is used to read a document, the Read override is called
many times and I can see the document contents being stepped through
using base.LocalName etc. What I don't understand is that the other
three overrides are never called. Samples I've found on Google seem to
indicate that all ReadXXX methods are called when a relevant document
item is encountered but that isn't happening in this case.

My aim is to replace an attribute value on all occurances of a specific
element. I can add code into the Read() override to identify when the
reader is processing that element, but need to override the behaviour of
ReadString() so I can substitute the new attribute value.

Thanks,
Ian
Jan 11 '06 #1
3 1512
Seems like you could accomplish the same goal, easily using XSLT without
using XmlTextReader.

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Ian Harding" <ih*********@hotmail.com> wrote in message
news:42*************@individual.net...
I have a class derived from XmlTextReader. It implements the following
methods:
public override void ReadEndElement()
public override void ReadStartElement()
public override string ReadString()
public override bool Read()

When the class is used to read a document, the Read override is called
many times and I can see the document contents being stepped through using
base.LocalName etc. What I don't understand is that the other three
overrides are never called. Samples I've found on Google seem to indicate
that all ReadXXX methods are called when a relevant document item is
encountered but that isn't happening in this case.

My aim is to replace an attribute value on all occurances of a specific
element. I can add code into the Read() override to identify when the
reader is processing that element, but need to override the behaviour of
ReadString() so I can substitute the new attribute value.

Thanks,
Ian

Jan 12 '06 #2
Naraendira Kuma R.R. wrote:
Seems like you could accomplish the same goal, easily using XSLT without
using XmlTextReader.


I was trying to keep overhead to a minimum. What I've read indicates
that reading a document with an XmlReader should be more efficient that
XSLT in this case. The XML document arrives in a string, the
XmlTextReader isolates one part of the document (an ADO Recordset) into
another string, then the Recordset is de-serialized from the XML.

On the other hand, if there's no way of substituting an attribute value
using an XmlReader, I might have to go the XSLT route.

Thanks,
Ian
Jan 12 '06 #3
Yes, XmlReader will be more efficient. Attributes are read by the
XmlDocument via MoveToNextAttribute, then each attribute value is acessed
via the Value property, so it's probably the Value property that you'll need
to override, and perhaps MoveToNextAttribute() also, to remember which
attribute you are positioned on.

"Ian Harding" <ih*********@hotmail.com> wrote in message
news:42*************@individual.net...
Naraendira Kuma R.R. wrote:
Seems like you could accomplish the same goal, easily using XSLT without
using XmlTextReader.


I was trying to keep overhead to a minimum. What I've read indicates that
reading a document with an XmlReader should be more efficient that XSLT in
this case. The XML document arrives in a string, the XmlTextReader
isolates one part of the document (an ADO Recordset) into another string,
then the Recordset is de-serialized from the XML.

On the other hand, if there's no way of substituting an attribute value
using an XmlReader, I might have to go the XSLT route.

Thanks,
Ian

Jan 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Meir S. | last post by:
I think the following is a bug in XmlTextReader: I need to process large XMLs, that are typically constructed of many small elements nested in the root element. Each inner element represents a...
2
by: Yuriy | last post by:
Hi, any ideas how to read XML fragment from TextReader? XmlTextReader constructor accepts only Stream or string as source Do I miss something? thanks Yuriy
2
by: ecomputerdelicacy | last post by:
Compact Framework SP3 (and I think also SP2 and SP1) XmlTextReader does not handle !DOCTYPE and (maybe?) rdf elements. How can I get the XmlTextReader to read these without issuing a...
1
by: RJN | last post by:
Hi I'm using XMLTextReader to parse the contents of XML. I have issues when the xml content itself has some special characters like & ,> etc. <CompanyName>Johnson & Jhonson</CompanyName>...
2
by: Q | last post by:
I am feeding XmlTextReader a URL that returns the XML that then gets parsed. The URL forms a query that affects how much data is returned in XML but not the format of the data. The problem is...
3
by: MFRASER | last post by:
I am trying to import some data into my objects and I have been using XMLDoc.LoadXML(file), but someone told me that this is very memory intensive that if I am reading a text file that I would be...
2
by: XML reading with XMLTextReader | last post by:
im trying to read an xml file which is in the wwwroot folder.im using IIS on XP Prof. my code is...
4
by: CodeRazor | last post by:
I am reading an xml file from a URL. I was originally doing this using the XmlDocument class. But this was very slow. The XmlTextReader is meant to be much quicker for forward only retrieval of...
4
by: CodeRazor | last post by:
I am trying to use an XmlTextReader to retrieve data. I need to use an XmlTextReader because it is faster than using an XmlDocument. I have found an inelegant way of retrieving each item's title...
2
by: =?Utf-8?B?TWlzY2hh?= | last post by:
It is my understanding that I can create an XmlTextReader from a variety of sources, including a stream object. I am developing a web application that reads some data from an Xml file. Everything...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.