Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Suggestions for Python XML library which can search and insert

Reply
Thread Tools

Suggestions for Python XML library which can search and insert

 
 
lainedacier@gmail.com
Guest
Posts: n/a
 
      07-26-2005
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.

 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-26-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

 
Reply With Quote
 
 
 
 
lainedacier@gmail.com
Guest
Posts: n/a
 
      07-26-2005
> 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!

 
Reply With Quote
 
uche.ogbuji@gmail.com
Guest
Posts: n/a
 
      07-29-2005
"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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: .NET and Python Integration Problem and PDF Library (Need Helpand Suggestions) Ravi Kumar Python 2 12-19-2007 06:43 AM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Suggestions for Python XML library which can search and insert lainedacier@gmail.com Python 6 07-29-2005 11:39 PM
search within a search within a search - looking for better way...my script times out Abby Lee ASP General 5 08-02-2004 04:01 PM



Advertisments