×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    33

    How to save a xml file?

    when I use minidom to parse and edit an xml file, it is like this :

    import xml.dom.minidom
    doc = xml.dom.m
    inidom.parse(XmlFile)

    then all the editing is done to the object, 'doc'. Then how do I save 'doc' as an xml file?

    Thanks

  2. #2
    Super Contributor
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622

    Re: How to save a xml file?

    Hi yanhua,

    Where is the documentation for minidom?

    What do you get if your print doc? Is there a to_string, to_file...?? available on a minidom object?

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

  3. #3
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: How to save a xml file?

    Quote Originally Posted by yanhua View Post
    when I use minidom to parse and edit an xml file, it is like this :

    import xml.dom.minidom
    Are you using xml.dom.minidom in Pys60?
    If the answer is yes, could you tell me how did you do it?

    (I'm using sgmllib to do some basic xml-parsing, but xml.dom.minidom would be much more convenient.)

  4. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    33

    Re: How to save a xml file?

    How did i do it?

    I just copy the xml library into the phone. and the console and find it automatically

    Is this what you want to know?

  5. #5
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: How to save a xml file?

    Quote Originally Posted by yanhua View Post
    I just copy the xml library into the phone. and the console and find it automatically.
    Is this what you want to know?
    I thought xml.dom.minidom needs expat...

    Could you name all the files you copied to the phone?

  6. #6
    Registered User
    Join Date
    Sep 2007
    Posts
    33

    Re: How to save a xml file?

    o wait ,
    i encountered such problem:

    i did imported xml.dom.minidom in the phone, and when i run this :
    f = xml.dom.minidom.parse('book.xml')
    the console says:

    ImportError: No module named pyexpat

    =====================================

    I'm sorry if i have misled u

    btw, what module is usually used for xml processing in pys60?
    could it be the elementTree or something?
    Last edited by yanhua; 2007-09-29 at 19:54.

  7. #7
    Registered User
    Join Date
    Sep 2007
    Location
    Gujrat,India
    Posts
    10

    Re: How to save a xml file?

    Extension markup language is same as HTML some syntax are different
    to save xml python u should work with xml.dom.minidom module find this module here.....docs.python.org/lib/module-xml.dom.minidom.html
    When we save and load different xml tags we must keep the same xml tags

    thx..
    Keyur Tank, B.E.I.T
    Gujrat, India

    Pys-60 1.4.0 with Nokia N-72
    Symbian C++,Python

  8. #8
    Regular Contributor
    Join Date
    Jul 2005
    Location
    Espoo, Finland
    Posts
    66

    Re: How to save a xml file?

    Quote Originally Posted by yanhua View Post
    btw, what module is usually used for xml processing in pys60?
    could it be the elementTree or something?
    You can use elementTree or even minidom if you install pyexpat. One good option is also to use xmllib.py, since it is pure Python implementation and does not require to install any 3rd party modules. xmllib.py comes with standard Python distribution.

    - Teemu

  9. #9
    Super Contributor
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622

    Re: How to save a xml file?

    True, but pure Python means slower when large documents need to be parsed. cElementTree is very fast once loaded! I've used it on few projects already.

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

Similar Threads

  1. Replies: 3
    Last Post: 2006-09-20, 08:07
  2. File save problem
    By zwgoal in forum Symbian
    Replies: 3
    Last Post: 2005-11-11, 10:11
  3. File Save!
    By georgica1979 in forum Symbian User Interface
    Replies: 7
    Last Post: 2003-04-11, 20:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×