newb: lxml objectify

Discussion in 'Python' started by johnny, Mar 30, 2007.

  1. johnny

    johnny Guest

    <Library>
    <DVD id="1">
    <title>Breakfast at Tiffany's</title>
    <format>Movie</format>
    <genre>Classic</genre>
    </DVD>

    <DVD id="2">
    <title>Borat</title>
    <format>Movie</format>
    <genre>Comedy</genre>
    </DVD>
    </Library>

    How do you represent DVD id=1 and it's elements, and DVD id=2 and it's
    elements as child of root "Library"?
    Like this:?

    from lxml import etree
    from lxml import objectify

    root = objectify.Element("Library")
    child[1] = objectify.Element("DVD", id="1")
    root.new_child = child[1]

    Thank you
     
    johnny, Mar 30, 2007
    #1
    1. Advertisements

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.
Similar Threads
  1. David Mertz, Ph.D.

    Article on updates to gnosis.xml.objectify

    David Mertz, Ph.D., Dec 4, 2004, in forum: Python
    Replies:
    0
    Views:
    373
    David Mertz, Ph.D.
    Dec 4, 2004
  2. Stefan Behnel
    Replies:
    0
    Views:
    510
    Stefan Behnel
    Oct 17, 2005
  3. Stefan Behnel

    [ANN] lxml 0.9 is out!

    Stefan Behnel, Mar 20, 2006, in forum: Python
    Replies:
    0
    Views:
    419
    Stefan Behnel
    Mar 20, 2006
  4. Stefan Behnel

    [ANN] lxml 1.0 released

    Stefan Behnel, Jun 2, 2006, in forum: Python
    Replies:
    2
    Views:
    552
    Stefan Behnel
    Jun 3, 2006
  5. Srijit Kumar Bhadra

    lxml and SimpleXMLWriter

    Srijit Kumar Bhadra, Jul 1, 2006, in forum: Python
    Replies:
    2
    Views:
    582
    Stefan Behnel
    Jul 6, 2006
  6. Jan Dries

    lxml Windows binaries

    Jan Dries, Sep 14, 2006, in forum: Python
    Replies:
    5
    Views:
    2,276
    Jan Dries
    Sep 14, 2006
  7. Wang, Harry

    gnosis XML objectify

    Wang, Harry, Nov 26, 2007, in forum: Python
    Replies:
    6
    Views:
    1,036
    Stefan Behnel
    Nov 27, 2007
  8. Wang, Harry

    gnosis XML objectify

    Wang, Harry, Nov 26, 2007, in forum: Python
    Replies:
    0
    Views:
    329
    Wang, Harry
    Nov 26, 2007
Loading...