473,799 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML reading issue....

I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateI d</key>
<string>AFL9124 395098</string>
............... ............
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader try
to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself and
it's going to be alllright.
Is there a way I could skip over it?

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
Aug 28 '06 #1
6 1513
"Lloyd Dupont" <net.galador@ld wrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
>I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateI d</key>
<string>AFL9124 395098</string>
............... ...........
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader try
to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself
and it's going to be alllright.
Is there a way I could skip over it?
I believe that if you set the XmlResolver property of the XmlTextReader to
null, it will ignore the remote DTD. If that doesn't do it, you could define
your own XmlResolver derived class which processes the remote DTD in any way
you like.

John
Aug 28 '06 #2
Thanks John!

However that doesn't work, if I disable the DTD, I get an XmlException: "The
DTD is deactivate, activate it this way..."

So I'm stuck between a rock and a hard place.
I don't want to valid the DTD because there is no network and the XML reader
doesn't want to read the XML document because the DTD is not validated...

"John Saunders" <john.saunder s at trizetto.comwro te in message
news:uP******** ******@TK2MSFTN GP03.phx.gbl...
"Lloyd Dupont" <net.galador@ld wrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
>>I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliate Id</key>
<string>AFL912 4395098</string>
.............. ............
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader
try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReade r or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself
and it's going to be alllright.
Is there a way I could skip over it?

I believe that if you set the XmlResolver property of the XmlTextReader to
null, it will ignore the remote DTD. If that doesn't do it, you could
define your own XmlResolver derived class which processes the remote DTD
in any way you like.

John


Aug 28 '06 #3
Lloyd Dupont wrote:
Thanks John!

However that doesn't work, if I disable the DTD, I get an XmlException: "The
DTD is deactivate, activate it this way..."

So I'm stuck between a rock and a hard place.
I don't want to valid the DTD because there is no network and the XML reader
doesn't want to read the XML document because the DTD is not validated...
Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).

Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
"John Saunders" <john.saunder s at trizetto.comwro te in message
news:uP******** ******@TK2MSFTN GP03.phx.gbl...
>"Lloyd Dupont" <net.galador@ld wrote in message
news:%2******* ***********@TK2 MSFTNGP02.phx.g bl...
>>I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliat eId</key>
<string>AFL91 24395098</string>
............. .............
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader
try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextRead er or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself
and it's going to be alllright.
Is there a way I could skip over it?
I believe that if you set the XmlResolver property of the XmlTextReader to
null, it will ignore the remote DTD. If that doesn't do it, you could
define your own XmlResolver derived class which processes the remote DTD
in any way you like.

John


Aug 28 '06 #4
>However that doesn't work, if I disable the DTD, I get an XmlException:
>"The DTD is deactivate, activate it this way..."

So I'm stuck between a rock and a hard place.
I don't want to valid the DTD because there is no network and the XML
reader doesn't want to read the XML document because the DTD is not
validated...

Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).
I had avoid that if I could.
That makes it forgetfulness prone. Our Mac developer edit the fil with the
PList editor which puts that in. Every time they edit a file I will have to
go after them.....
>
Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.
that's interesting! how do I do that?
I tryed to set my own XmlResolver but, unless I write a bug during my
experimentation , that didn't work... (I'm a bit suspicious though...)
///Peter
--
XML FAQ: http://xml.silmaril.ie/
>"John Saunders" <john.saunder s at trizetto.comwro te in message
news:uP******* *******@TK2MSFT NGP03.phx.gbl.. .
>>"Lloyd Dupont" <net.galador@ld wrote in message
news:%2****** ************@TK 2MSFTNGP02.phx. gbl...
I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affilia teId</key>
<string>AFL9 124395098</string>
............ ..............
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader
try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReade r or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading
myself and it's going to be alllright.
Is there a way I could skip over it?
I believe that if you set the XmlResolver property of the XmlTextReader
to null, it will ignore the remote DTD. If that doesn't do it, you could
define your own XmlResolver derived class which processes the remote DTD
in any way you like.

John

Aug 28 '06 #5
Lloyd Dupont wrote:
>>I don't want to valid the DTD because there is no network and the XML
reader doesn't want to read the XML document because the DTD is not
validated.. .
[me]
>Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).
[lloyd]
I had avoid that if I could.
That makes it forgetfulness prone. Our Mac developer edit the fil with the
PList editor which puts that in. Every time they edit a file I will have to
go after them...
OK, I thought this might be an automated process.

[me]
>Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.
[lloyd]
that's interesting! how do I do that?
sed -e "s+http://www.apple.com+f ile:///some/directory+" old.xml >new.xml

This leaves you with output that starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"/some/directory/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

All you need to do is make sure you have a directory in the relevant
place in your tree called /some/directory/DTDs, and in it a copy of the
PropertyList-1.0.dtd file (which you get from Apple; plus any ancillary
files it references).

Now when you edit/process the document, it will validate against the
local copy. You can replace /some/directory with whatever is suitable
for your system.

sed is available for Microsoft systems both with and without Cygwin
support, I believe.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Aug 29 '06 #6
mmh....
thanks ;-)

"Peter Flynn" <pe********@m.s ilmaril.iewrote in message
news:4l******** ****@individual .net...
Lloyd Dupont wrote:
>>>I don't want to valid the DTD because there is no network and the XML
reader doesn't want to read the XML document because the DTD is not
validated. ..
[me]
>>Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).
[lloyd]
>I had avoid that if I could.
That makes it forgetfulness prone. Our Mac developer edit the fil with
the PList editor which puts that in. Every time they edit a file I will
have to go after them...

OK, I thought this might be an automated process.

[me]
>>Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.
[lloyd]
>that's interesting! how do I do that?

sed -e "s+http://www.apple.com+f ile:///some/directory+" old.xml >new.xml

This leaves you with output that starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"/some/directory/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

All you need to do is make sure you have a directory in the relevant place
in your tree called /some/directory/DTDs, and in it a copy of the
PropertyList-1.0.dtd file (which you get from Apple; plus any ancillary
files it references).

Now when you edit/process the document, it will validate against the
local copy. You can replace /some/directory with whatever is suitable for
your system.

sed is available for Microsoft systems both with and without Cygwin
support, I believe.

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Sep 1 '06 #7

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

Similar topics

2
10702
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It appears to be in the OLEDB driver also. My connection was: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";" & "Extended Properties='Text;HDR=NO;FMT=Delimited'"
4
2086
by: Mark Stijnman | last post by:
A while ago I posted a question about how to get operator behave differently for reading and writing. I basically wanted to make a vector that can be queried about whether it is modified recently or not. My first idea, using the const and non-const versions of operator, was clearly not correct, as was pointed out. Julián Albo suggested I could use proxies to do that. I've done some googling for proxies (also in this group) and personally,...
0
1024
by: Webster | last post by:
Hello, I have a program that asynchronously reads data from a host. However, whenever I call the BeginRead function, the async reading "loop" never seems to terminate. Why doesn't the EndRead method return 0 when it is done reading?? This is the pseudo-code for my callback function: ReadData
7
6063
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should populate a series of structures of specified variable composition. I have the structures created OK, but actually reading the files is giving me an error. Can I ask a simple question to start with: I'm trying to read the file using the...
10
2144
by: Johhny | last post by:
Hello All, I am working my way through learning python as a language. I am having some issues with something that looks right and does not work. I am trying to get myself more familure with reading files. Based on the tutorials at www.python.org This "should" work. but im not sure what the issue is. ===SNIP=== import string
2
1629
by: RR | last post by:
I'm trying to read an xml file into a dataset just like I do in my windows application. DataSet.ReadXML("filename.xml"); But no matter how I have the string file name the application errors and I get File Not Found when I debug on the emulator. Since I'm fairly new to mobile development, do I need to do anything in particular to load the xml file to the emulator / device? The xml file is in the project folder.
5
5089
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I have it store info it gets from when the programs check in into a DataSet (XML file). Problem is, that file now has to be used by other programs to find out version information (the file is ALWAYS less that 1K.) The record itself is only five fields...
111
20081
by: Tonio Cartonio | last post by:
I have to read characters from stdin and save them in a string. The problem is that I don't know how much characters will be read. Francesco -- ------------------------------------- http://www.riscossione.info/
6
3533
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features to an old program that I wrote in delphi and it's a good opportunity to start with c++.
9
14403
by: Hal Vaughan | last post by:
I've done a fair amount of Googling for information on reading the serial port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to be an unanswered question, 1 is someone saying, "That's easy, there's a lot out there, Google it,", 1 is a discussion on it without examples and the other is who knows what. I did find some info on it and have been experimenting. The one example that I liked the best in terms of...
0
9687
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10029
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6808
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
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.