473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

problem calling ElementTree._ElementInterface.find withPyObject_CallObject

I have a weid problem. If i do this:
import elementtree.ElementTree as ET
....
tree = ET.parse("whatever")
root = tree.getroot()
r = root.find('last')
print r
return root
where last is not an immediate child of root node i get back None.
However if i comment the r = root.find('last')
print r
part out and PyObject_CallObject on root from c++ space
i get

Traceback (most recent call last):
File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementTree.py", line 329, in find
return ElementPath.find(self, path)
File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementPath.py", line 188, in find
return _compile(path).find(element)
File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementPath.py", line 178, in _compile
p = Path(path)
File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementPath.py", line 70, in __init__
tokens = xpath_tokenizer(path)
AttributeError: _ElementInterface instance has no attribute 'last'

(the call to PyObject_CallObject works fine if root.find on the
requested attribute was performed first
from python space!!!)

this is with ElementTree 1.2.6 if that matters here at all
Nov 15 '07 #1
0 1482

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dayzman | last post by:
Hi all, I'm using TidyHTMLTreeBuilder to model syntax structure of HTML documents. I've been trying to feed in Yahoo and CNN, but the parser seems to crash: " File...
4
by: Matthew Thorley | last post by:
I am trying to inherit from ElementTree so I can add some methods. This is the code I am trying to make work, and the following is the error I am getting. from elementtree import ElementTree...
1
by: mirandacascade | last post by:
I do not understand how to use the find() method in ElementTree. The file 'sample.xml' is: <?xml version="1.0"?> <SampleRoot> <Header> <Product>FindMystery</Product> </Header>...
0
by: Chris McDonough | last post by:
ElementTree's XML serialization routine implied by tree._write(file, node, encoding, namespaces looks like this (elided): def _write(self, file, node, encoding, namespaces): # write XML to file...
0
by: Greg Aumann | last post by:
I am trying to write some python code for a library that reads an XML-like language from a file into elementtree data structures. Then I want to be able to read and/or modify the structure and then...
2
by: mirandacascade | last post by:
Situation is this: 1) I have inherited some python code that accepts a string object, the contents of which is an XML document, and produces a data structure that represents some of the content of...
0
by: Mark | last post by:
-------- Original Message -------- Subject: Using cElementTree and elementtree.ElementInclude Date: Mon, 23 Oct 2006 09:40:24 -0500 From: Mark E. Smith <mark.e.smith@arnold.af.mil> Organization:...
1
by: Mike Slinn | last post by:
The following short Python program parses a KML file and displays the names of all Marks and Routes: from elementtree.ElementTree import ElementTree tree = ElementTree(file='test.kml') kml =...
2
by: Zvi | last post by:
Hi All, Can someone tell me why id the following not working? I have a soap response envelope, for test purpose it's just a string and I create ElementTree from it. Then I try to find Response...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.