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. 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.
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:
    278
    David Mertz, Ph.D.
    Dec 4, 2004
  2. Stefan Behnel
    Replies:
    0
    Views:
    378
    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:
    301
    Stefan Behnel
    Mar 20, 2006
  4. Wang, Harry

    gnosis XML objectify

    Wang, Harry, Nov 26, 2007, in forum: Python
    Replies:
    6
    Views:
    921
    Stefan Behnel
    Nov 27, 2007
  5. Wang, Harry

    gnosis XML objectify

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

Share This Page