ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: Error when attempting to use cloneNode - Can't locate object method "cloneNode" via package "XML::DOM::NodeList"
by James Woodworth other posts by this author
Jul 25 2007 12:49PM messages near this date
view in the new Beta List Site
Re: Error when attempting to use cloneNode - Can't locate object method "cloneNode" via package "XML::DOM::NodeList" | Re: Error when attempting to use cloneNode - Can't locate object method "cloneNode" via package "XML::DOM::NodeList"
& XSLT Hello John,
   
  i recently started using XML::LibXML.  what i did was made a "deep" clone for a set of ele
ments to repeatedly insert the clone onto the end after some modifications to the attributes
.  try this:
   
  my $cloned_node = $node-> cloneNode( 1 );
  ...then...
  my $last_node = ( $document-> findnodes( '/root_node/plot[last()]' ) )[0];
  $last_node-> addSibling( $cloned_node );
   
  reply if you need to insert some whitespace.
   
  hth, jim woodworth

John Krewson <jkroogle@[...].com>  wrote:
  Bjoern,

This is my first time using Perl to work with XML in this way, so my reasoning for using XML
::DOM is simply based upon some examples I have found. Do you think it would be better to us
e XML::LibXML when making a copy of data in one file to paste into another? 

My thought was that cloning the node would be easiest way to simple grab all the content bet
ween <Article> </Article> so that this data could be pasted into another XML file.  Basically
, I have a lot of 'stand alone' files that contain content, and I need to consolidate that c
ontent into one main XML file. 

Ex:
a = clone of <Article> nodes between</Article>
then
paste in between <Articles> </Articles> in another file.

Thanks very much for your response.

  On 7/25/07, Bjoern Hoehrmann <derhoermi@[...].net>  wrote:  * John Krewson wrote:
> I am getting the following error when attempting to use cloneNode, in order
> to clone a node and then paste this node into a target file:
> Can't locate object method "cloneNode" via package "XML::DOM::NodeList" 

If you have XML::LibXML I don't think there is any reason to use
XML::DOM. As for your problem, getElementsByTagName returns a node
list (zero or more nodes); you are trying a method for a single
node on a list of nodes, you have to clone the nodes one by one. 
Not that I am sure why you are trying to clone them in the first
place.
--
Bj�rn H�hrmann � mailto:bjoern@[...].de � http://bjoern.hoehrmann.de 
Weinh. Str. 22 � Telefon: +49(0)621/4309674 � http://www.bjoernsworld.de
68309 Mannheim � PGP Pub. KeyID: 0xA4357E78 � http://www.websitedev.de/ 


_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


       
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
Thread:
John Krewson
Bjoern Hoehrmann
John Krewson
Richard E. Rathmann
John Krewson
James Woodworth
John Krewson

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved