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
Error when attempting to use cloneNode - Can't locate object method "cloneNode" via package "XML::DOM::NodeList"
by John Krewson other posts by this author
Jul 25 2007 11:35AM messages near this date
view in the new Beta List Site
Re: XML::LibXML::Reader | Re: Error when attempting to use cloneNode - Can't locate object method "cloneNode" via package "XML::DOM::NodeList"
& XSLT Greetings,

I'm pulling my hair out with this one as it seems to me it should work based
upon the examples I have found.  I'm worried that I need to update a module
but I don't have the rights to do so - it would take longer than the
timeline on this particular task )-:  I wonder if someone might have a
sample, full script that uses cloneNode so I can check to see if I might be
missing something?

I am running the following version of Perl:
This is perl, version 5.005_03 built for sun4-solaris

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"

Here are the related modules I am including:

use XML::LibXSLT;
use XML::LibXML;
use XML::DOM;
use XML::Parser;

And here is the tiny code block that is driving me nuts:

#### Source
    my $parser = XML::DOM::Parser-> new();
    my $source_xml  = $parser-> parsefile($article_xml);
    my $target_xml  = $parser-> parsefile($article_xml);

    #### Try the cloning technique
    my $article = $source_xml-> getElementsByTagName('Article');
    my $clone = $article-> cloneNode("deep"); # do a deep clone

Here is the source XML:
?xml version='1.0' encoding='utf-8' ?> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://w
ww.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

        <Article> 
        <id> 1378264</id><section>AH RECIPES OTHER</section><create_date>Sep
05 2
002 05:28:12:000AM</create_date> <last_updated_date>May 07 2007
06:41:54:000PM</l
ast_updated_date> <publication_date>May 24,
2002</publication_date> <headline>Cook
ing with Garlic</headline> <url>
http://www.hgtv.com/hgtv/ah_recipes_other/article
/0,1801,HGTV_3186_1378264,00.html</url> <copyright>Copyright 2007,
</copyright> 
        </Article> 

Here is the target:
<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.or
g/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<articles> 
<article version="1.1" article_xml_create_date="July 09 2007
04:00:00:000PM"> 
</articles> 
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