Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > importing node into document

Reply
Thread Tools

importing node into document

 
 
Ajay
Guest
Posts: n/a
 
      08-14-2004
hi!

is there an equivalent for the Java document.importNode in Python
what i am trying to do is to import a node from a different document into
the current document and then append it one of the nodes in the current
document
tempNode.ownerDocument = node.ownerDocument
#the above gives an error saying i am trying to modify a reda-only
attribute
#if i omit the statement, the statement below throws an error saying they
#the nodes are from different document
node.appendChild(tempNode)

thanks

cheers






----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
 
Reply With Quote
 
 
 
 
Ivan Herman
Guest
Posts: n/a
 
      08-15-2004
In terms of XML two documents represent two different 'worlds'; a Node
also includes a reference to its own document, ie, you cannot easily
mix/merge etc, nodes in different namespaces. This reference is read
only. (As I already answered in one of your other messages, you should
really consider looking at the original DOM specification. That clearly
flags the 'ownderDocument' as 'readonly'!).

What you have to do is (recursively) create a new node in your target
document with the name of the original, then copy the attributes and
(recursively) the children.

Ivan





Ajay wrote:

> hi!
>
> is there an equivalent for the Java document.importNode in Python
> what i am trying to do is to import a node from a different document into
> the current document and then append it one of the nodes in the current
> document
> tempNode.ownerDocument = node.ownerDocument
> #the above gives an error saying i am trying to modify a reda-only
> attribute
> #if i omit the statement, the statement below throws an error saying they
> #the nodes are from different document
> node.appendChild(tempNode)
>
> thanks
>
> cheers
>
>
>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.

 
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
importing an xml node into an xhtml one Une Bévue Javascript 4 04-12-2008 03:36 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
How to keep a module with the same name as a module it is importing from importing itself? plb Python 2 02-08-2005 03:14 PM
import node into document Ajay Python 0 08-15-2004 03:10 AM



Advertisments