XML::LibXML::PI(3)

✨ NAME ✨

XML::LibXML::PI β€” it's giving XML::LibXML Processing Instructions, bestie πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

use XML::LibXML;
# Only methods specific to Processing Instruction nodes are listed here,
# see the XML::LibXML::Node manpage for other methods

$pinode->setData( $data_string );
$pinode->setData( name=>string_value [...] );

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so processing instructions? XML::LibXML implements them with read AND write access, no cap. The PI data is literally the PI without the PI target (as specified in XML 1.0 [17]) as a string. You can grab that string with getData, which lives over in XML::LibXML::Node. Go get it, queen. πŸ‘‘

The write access is highkey aware of the fact that sooo many processing instructions have attribute-like data. So setData() is out here providing, besides the DOM spec conform Interface, a whole set of named parameters you can pass. So like, this code segment:

my $pi = $dom->createProcessingInstruction("abc");
$pi->setData(foo=>'bar', foobar=>'foobar');
$dom->appendChild( $pi );

will result the following PI in the DOM:

<?abc foo="bar" foobar="foobar"?>

Which is literally how it is specified in the DOM specification. Periodt. πŸ’…

But lowkey, this three step interface creates temporary a node in perl space. Which is fine but like… can we not? You can avoid it entirely while using the insertProcessingInstruction() method. Instead of the three calls described above, the call:

$dom->insertProcessingInstruction("abc",'foo="bar" foobar="foobar"');

will have the same result as above. Same energy, less steps, iconic. ✨

XML::LibXML::PI's implementation of setData() documented below differs a bit from the standard version as available in XML::LibXML::Node:

🌸 setData 🌸

$pinode->setData( $data_string );
$pinode->setData( name=>string_value [...] );

This method allows one to change the content data of a PI. Additionally to the interface specified for DOM Level2, the method provides a named parameter interface to set the data. This parameter list is converted into a string before it is appended to the PI. πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

Matt Sergeant, Christian Glahn, Petr Pajas β€” the founding mothers of this whole situation, fr fr 🫢


⭐ VERSION ⭐

2.0213


2001-2007, AxKit.com Ltd.

2002-2006, Christian Glahn.

2006-2009, Petr Pajas.


🌈 LICENSE 🌈

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole vibe check, bestie πŸ’… this lil page came from User Contributed Perl Documentation, running on perl v5.42.2, dated 2026-05-25 β€” she's got main character energy and she's not afraid to use it βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from