Suggestions for Python XML library which can search and insert

Discussion in 'XML' started by lainedacier@gmail.com, Jul 26, 2005.

  1. Guest

    Hi,

    I'm looking for a library that can search through an XML document tree,
    locate an element by attribute (ideally this can be done through
    XPath), and insert an element (as its child).

    Simple? Yes? ...but the code I've seen so far which does this uses
    'nested for loops' for trees which are relatively shallow compared to
    mine. So I'm wondering if you could give me some suggestions as to
    which XML library could do this without resorting to nested for loops,
    and/or better yet, what's the trend in this type of operation?

    Thanks in advance.
     
    , Jul 26, 2005
    #1
    1. Advertising

  2. wrote:

    > Simple? Yes? ...but the code I've seen so far which does this uses
    > 'nested for loops' for trees which are relatively shallow compared to
    > mine. So I'm wondering if you could give me some suggestions as to
    > which XML library could do this without resorting to nested for loops,
    > and/or better yet, what's the trend in this type of operation?


    Why do you care if they are nested for loops?

    What is the problem you are experiencing that is caused
    by for loops?

    Does the software you've seen not work with your XML
    trees? What error do you get when you try it?

    Or are you just opposed to for loops on philosophical
    grounds?


    --
    Steven.
     
    Steven D'Aprano, Jul 26, 2005
    #2
    1. Advertising

  3. Guest

    > Why do you care if they are nested for loops?
    >
    > What is the problem you are experiencing that is caused
    > by for loops?
    >


    The nested loops which I speak of are highly dependent
    on the structure of the document tree. The examples which
    I've seen using DOM or ElementTree deal with shallow trees,
    but in my case, I am dealing with deeper trees--which means
    that the degree of nesting would also grow deeper if I were
    to follow suit. Also, it makes for hard to manage code.

    I'd say that lxml is exactly what I'm looking for, because
    it supports XPath and Robert Kern's example is pretty reassuring.
    Thanks Robert Kern!
     
    , Jul 26, 2005
    #3
  4. Guest

    "I'm looking for a library that can search through an XML document
    tree,
    locate an element by attribute (ideally this can be done through
    XPath), and insert an element (as its child).

    Simple? Yes? ...but the code I've seen so far which does this uses
    'nested for loops' for trees which are relatively shallow compared to
    mine. "

    Amara can easily do this using XPath (complete with predicates,
    functions, etc.), without nested for loops:

    http://uche.ogbuji.net/tech/4Suite/amara/

    --
    Uche
    http://uche.ogbuji.net
     
    , Jul 30, 2005
    #4
    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. jkflens
    Replies:
    2
    Views:
    1,535
    jkflens
    May 30, 2006
  2. Replies:
    6
    Views:
    324
  3. Ravi Kumar
    Replies:
    2
    Views:
    268
    Ravi Kumar
    Dec 19, 2007
  4. Sammy
    Replies:
    1
    Views:
    333
    NET_NET_2003
    Aug 18, 2003
  5. Abby Lee
    Replies:
    5
    Views:
    449
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page