How to get an XML DOM while offline?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • william tanksley

    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
  • william tanksley

    #2
    Re: How to get an XML DOM while offline?

    "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
    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.
    Diez
    -Wm

    Comment

    • Stefan Behnel

      #3
      Re: How to get an XML DOM while offline?

      william tanksley wrote:
      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.



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



      Stefan

      Comment

      Working...