Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7918105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:23:34+00:00 2026-06-03T15:23:34+00:00

I need to render a node set found via XML::XPath my $source = XML::LibXML->load_xml(location

  • 0

I need to render a node set found via XML::XPath

my $source = XML::LibXML->load_xml(location => 'xml/animals.xml');
my $nodeset = $source->find('//area[@id="01"]');

using an XSLT template with XML::LibXSLT:

my $xslt = XML::LibXSLT->new();
my $style_doc = XML::LibXML->load_xml(location=>'xml/animal_template.xsl', no_cdata=>1);
my $stylesheet = $xslt->parse_stylesheet($style_doc);

but I can’t simply give the nodeset to the $stylesheet->transform():

my $results = $stylesheet->transform($nodeset);

because transform is expecting a XML::LibXML::Document object, not XML::XPath::NodeSet.

What should I do? Is there a way to create an XML::LibXML::Document from a XML::XPath::NodeSet?

Or maybe to give the XSLT template a variable so I don’t have to find the nodes with XPath?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:23:35+00:00Added an answer on June 3, 2026 at 3:23 pm

    There is no direct method to convert an XML::XPath::NodeSet object to an XML::LibXML::Document object. Furthermore it isn’t possible in general as a Nodeset can contain any number of XML elements while an XML document must have exactly one root element.

    But XPath is an integral part of XSLT, so there is no reason why you shouldn’t rewrite the transform so that it does the selection //area[@id="01"] itself, and then supply it the entire document, as parsed by XML::LibXML. This is the method I would choose.

    If you have reasons to select the <area id="01"> elements separately then it would be possible to build a new XML document by converting each element in the Nodeset to a string and bundling them into a dummy <root> XML element, but that is far from an ideal solution.

    If you have questions about implementing a solution then please ask again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to render a partial view to a string within a controller action.
I need to render a 1027 * 768 bitmap to the client window (same
Let's just say that I need to render a certain amount of HTML over
I'm writing a game in python with pygame and need to render text onto
I have a report which is composed of several subreports. I need to render
I'm writing a retro type game for the iPhone, and need to render a
I need a page to always render in IE9 browser mode and document mode
Why is there a need to explicitly call GridView.DataBind() to render the gridview. Why
I want to write video filter for Adobe Premiere, and I need to print/draw/render
I need to render Graphviz DOT graphs in a browser. I also need some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.