473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting XmlTextReader to skip DOCTYPE in Compact Framework?

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 NotSupportedExc eption? Or at least to get past
these elements (and nested elements) with an Skip()? I've tried setting
xtr.XmlResolver = null; but it doesn't change the functionality. I'm still
getting the exception.

In a recent MSDN MVP Chat, I was pointed to http://tinyurl.com/5n827 where
it says "Support for parsing DTDs was removed to increase perf and size. It
was considered for .NetCF v2 but was cut again in favor of XmlSchema support."

I'm not asking for XML validation, just a usable way to read the rest of the
XML, while ignoring the DOCTYPE entity. It would be great if I can just
xtr.Skip(), or xtr.MoveToConte nt() around the DOCTYPE. In my code, if I get
an Exception, I currently try to xtr.Skip() around it, but with SP3, this
creates another NotSupportedExc eption. This may have worked at one time with
SP1 or SP2, I'm not sure. The various flavors of SP1, 2, 3 handle this in
slightly different ways, I think. But I haven't fully characterized this. I
just want this working with SP3 so I can suggest to my users to upgrade, if
necessary.

In desperation, along with xtr.XmlResolver = null; I've also tried
xtr.Namespaces = false; and xtr.Normalizati on = false;

Obviously to those who are more familiar with how XmlTextReader works, you
may notice that the above properties have nothing to do with my problem.

I have already had to kludge the Encoding because XmlTextReader does not
provide a way to extend the supported text encodings. I hope that I can get
around this DOCTYPE issue easily. I'm considering implementing my own XML
parser. It would be a shame if this becomes necessary. Parsing out the
encoding line is relatively easy (read until the first ">". Parsing the
DOCTYPE is much more difficult because it can include optional nested
elements.

While the XmlTextReader helped me greatly in getting my program going, it is
now in the way of reading some XML documents.
To email me: change to d from delicacy and yahoo from yahoozier.

Nov 12 '05 #1
2 3644
"ec************ ***@yahoozier.c om" <ec************ *************** @discussions.mi crosoft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
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 NotSupportedExc eption? Or at least to get past
these elements (and nested elements) with an Skip()?


XmlTextReader is going to get it's input from a Stream or TextReader
that you can supply. It can only throw a NotSupportedExc eption if
it *sees* your DTD. Therefore, what I would try is to subclass the
appropriate Stream or TextReader you're using as an input source
and write that subclass to "strip out" the DTD. Then your XmlText-
Reader can't see it and shouldn't throw an NSE.
Derek Harmon
Nov 12 '05 #2
Thanks! Your answer makes perfect sense. I *do* think the parsing of DTD in
Compact Framework is broken. It should throw the exception only if I'm trying
to validate. Or it should allow me to .Skip() past the DTD.

XmlTextReader on Compact Framework is apparently for tightly controlled
situations where you can control the writer and reader. It is not for generic
usage on a wide variety of XML input.

I want to be able to read the DTD without validating. And for this,
according to your suggestion, I have to subclass and pre-filter the DTD. I
thought DTDs can be nested, so does that mean I have to generate a recursive
filter. If I'm doing this, why not replace .NET XML with another parser that
can handle ignoring DTDs?

In my opinion, CF.NET XmlTextReader should fail a little more gracefully and
be allowed to fail silently (even if I have to catch the Exception, like I'm
already doing, and use .Skip() to get around the element). It's a little bit
disheartening to get this close with CF.NET XmlTextReader and not be able to
skip/ignore DTDs.

Change to d from delicacy and yahoo from yahoozier to email me (if you want!)

"Derek Harmon" wrote:
"ec************ ***@yahoozier.c om" <ec************ *************** @discussions.mi crosoft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
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 NotSupportedExc eption? Or at least to get past
these elements (and nested elements) with an Skip()?


XmlTextReader is going to get it's input from a Stream or TextReader
that you can supply. It can only throw a NotSupportedExc eption if
it *sees* your DTD. Therefore, what I would try is to subclass the
appropriate Stream or TextReader you're using as an input source
and write that subclass to "strip out" the DTD. Then your XmlText-
Reader can't see it and shouldn't throw an NSE.
Derek Harmon

Nov 12 '05 #3

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

Similar topics

3
2144
by: James | last post by:
I can get the windows version number from System.Environment.OSVersion e.g. "Windows NT 5.1.2600.0" for XP SP2. I was wondering whether this tells you the type of windows it is or if you have to use something else? E.g. for windows 2000 do you just get a version number, or can you tell if it is Professional, Server, Advanced Server,...
4
5357
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 command, so I have to parse and execute them according to the order they appear in the ROOT element. I don't want to use XmlDocument for the...
3
4205
by: keldan | last post by:
I am hoping someone on this list can shed some light on the below issue for me. I am using XmlTextReader to read from an XML file. Unfortunately, an exception is thrown ("Index was outside the bounds of the array.") when the reader reaches the DOCTYPE. If I remove it everything works fine. Should I be handling the DOCTYPE someway before...
4
5471
by: Bnaya Eshet | last post by:
I do like XPath, I really do. But I'm working on the compact framework which XPath is not included. So I come to understanding that if XPath do not come to the mountain,
1
4417
by: soupaman | last post by:
Im trying to output some filtered xml using the xmlTextReader I know the code and commenting needs cleaned up and eventually plan to add the values to a dataset. currently what this is doing is matching the filters, runs into the response.write and outputs nothing. I've used the dbgclr to verify that the filters are matching and it is hitting...
1
2244
by: SHC | last post by:
Hi all, I did the "Build" on the attached code in my VC++ .NET 2003 - Windows XP Pro PC. On the c:\ screen, I got the following: Microsoft Development Environment An unhandled exception of type 'System.Xml.XmlException' occured in system.xml.dll Addtional Information: System error |Break| |Continue| I clicked on the |Continue| and I got...
3
2824
by: Stephen S Kelley | last post by:
I want to do something like: bool bContinueReading=true; XmlTextReader Reader=new XmlTextReader("file.xml"); while(bContinueReading) { try { Reader.Read(); ...
5
3322
by: bob | last post by:
Hi Using 2003 - targeting the compact framework (c#), but would like to do most development using the full.net (manually leaving out stuff not in the compact framework). Q. Trying to find a way of converting a project to have builds for both compact and full. Project properties doesn't seem to help Thanks
4
6010
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 and description using string methods. See my code below. I would like to know how I can retrieve the <title> and <description> nodes more directly...
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.