Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 19th, 2008, 04:25 PM
william tanksley
Guest
 
Posts: n/a
Default How to get an XML DOM while offline?

I want to parse my iTunes Library xml. All was well, until I unplugged
and left for the train (where I get most of my personal projects
done). All of a sudden, I discovered that apparently the presence of a
DOCTYPE in the iTunes XML makes xml.dom.minidom insist on accessing
the Internet... So suddenly I was unable to do any work.

I don't want to modify the iTunes XML; iTunes rewrites it too often.
How can I prevent xml.dom.minidom from dying when it can't access the
Internet?

Is there a simpler way to read the iTunes XML? (It's merely a plist,
so the format is much simpler than general XML.)

-Wm
  #2  
Old March 31st, 2008, 06:05 PM
william tanksley
Guest
 
Posts: n/a
Default Re: How to get an XML DOM while offline?

"Diez B. Roggisch" <de...@nospam.web.dewrote:
Quote:
The most pragmatic solution would be to rip the doctype out using simple
string methods and/or regexes.
Thank you, Diez and Paul; I took Diez's solution, and it works well
enough for me.
Quote:
Diez
-Wm
  #3  
Old April 7th, 2008, 07:25 AM
Stefan Behnel
Guest
 
Posts: n/a
Default Re: How to get an XML DOM while offline?

william tanksley wrote:
Quote:
I want to parse my iTunes Library xml. All was well, until I unplugged
and left for the train (where I get most of my personal projects
done). All of a sudden, I discovered that apparently the presence of a
DOCTYPE in the iTunes XML makes xml.dom.minidom insist on accessing
the Internet... So suddenly I was unable to do any work.
>
I don't want to modify the iTunes XML; iTunes rewrites it too often.
How can I prevent xml.dom.minidom from dying when it can't access the
Internet?
>
Is there a simpler way to read the iTunes XML? (It's merely a plist,
so the format is much simpler than general XML.)
Try lxml. Since version 2.0, its parsers will not access the network unless
you tell it to do so.

http://codespeak.net/lxml

It's also much easier to use than minidom and much faster:

http://blog.ianbicking.org/2008/03/3...r-performance/

Stefan
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles