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
π COPYRIGHT π
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
- fedora 43: perl-XML-LibXML 1:2.0213-1.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- fedora 44: perl-XML-LibXML 1:2.0213-1.fc44 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms