Inserting an element into existing xml file

Discussion in 'Python' started by Anand, Sep 25, 2007.

  1. Anand

    Anand Guest

    Hi,

    I'm new to Python. we are using python2.4.

    I wanted to insert an element into an existing xml file. Can anyone
    help me with this?
    I've seen lxml and elementTree in python2.5 has some API's to insert
    into existing xml file.
    We cant use python 2.5 due to some limitations. So how can we do it in
    2.4?

    Thanks in Advance,
    Anand
    Anand, Sep 25, 2007
    #1
    1. Advertising

  2. Anand wrote:
    > I'm new to Python. we are using python2.4.
    >
    > I wanted to insert an element into an existing xml file. Can anyone
    > help me with this?
    > I've seen lxml and elementTree in python2.5 has some API's to insert
    > into existing xml file.
    > We cant use python 2.5 due to some limitations. So how can we do it in
    > 2.4?


    Install lxml and read the tutorial. It should be easy to grasp, as the API is
    very simple.

    http://codespeak.net/lxml/tutorial.html
    http://codespeak.net/lxml/tutorial.html#elements-are-lists

    It's compatible to ElementTree, which you can also install on Python 2.4 (it's
    what later became part of Python 2.5).

    Stefan
    Stefan Behnel, Sep 25, 2007
    #2
    1. Advertising

  3. Anand

    Anand Guest

    On Sep 25, 3:20 pm, Stefan Behnel <> wrote:
    > Anand wrote:
    > > I'm new to Python. we are using python2.4.

    >
    > > I wanted to insert an element into an existing xml file. Can anyone
    > > help me with this?
    > > I've seen lxml and elementTree in python2.5 has some API's to insert
    > > into existing xml file.
    > > We cant use python 2.5 due to some limitations. So how can we do it in
    > > 2.4?

    >
    > Install lxml and read the tutorial. It should be easy to grasp, as the API is
    > very simple.
    >
    > http://codespeak.net/lxml/tutorial.htmlhttp://codespeak.net/lxml/tutorial.html#elements-are-lists
    >
    > It's compatible to ElementTree, which you can also install on Python 2.4 (it's
    > what later became part of Python 2.5).
    >
    > Stefan



    Hi Stefan,

    First of all thanks for your reply.

    I'm Afraid to say, I can't use lxml or elementTree as it requires many
    legal approvals and there is high chances of not getting it through.
    So Do you have any other method / idea just by using plain 2.4 to
    accomplish the task

    Cheers,
    Anand
    Anand, Sep 25, 2007
    #3
  4. On Tue, 25 Sep 2007 03:30:05 -0700, Anand wrote:

    > I'm Afraid to say, I can't use lxml or elementTree as it requires many
    > legal approvals and there is high chances of not getting it through.


    In what environment is it hard to get something BSD licensed through!?

    Ciao,
    Marc 'BlackJack' Rintsch
    Marc 'BlackJack' Rintsch, Sep 25, 2007
    #4
  5. Anand wrote:

    > I'm Afraid to say, I can't use lxml or elementTree as it requires many
    > legal approvals and there is high chances of not getting it through.
    > So Do you have any other method / idea just by using plain 2.4 to
    > accomplish the task


    Are you allowed to use code samples you found on the net?

    http://svn.effbot.org/public/elementtree/

    (if not, are you even allowed to ask for help? ;-)

    ElementTree (aka xml.etree) is pure Python, and you only need the
    ElementTree.py module to do what you want, so I guess you could
    always pretend you wrote it yourself...

    </F>
    Fredrik Lundh, Sep 26, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page