
May 27th, 2004, 06:28 PM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: London, England
|
|
|
Perhaps you are using the wrong Node. In your example, <test2 cd="2">some text 2</test2> is actually composed of several Node objects:
* an Element node with the tagName of "test2", containing the following nodes:
* an attributes nodeList, containing an Attr object with a name of "cd" and a value of "2"
* childNodes - a list of Node objects, containing a Text object with a nodeValue of "some text 2"
If you are calling previousSibling on the Attr or Text objects then they will return None, since they have no siblings. If you call it on the Element object then you should get the previous Node in the DOM. this will probably be a Text node containing the white-space between the Elements, so you will need to step back through the previousSiblings until you find an Element object or None.
Dave - The Developers' Coach
|