| 1 |
=head1 NAME |
| 2 |
|
| 3 |
XML::LibXML::PI - XML::LibXML Processing Instructions |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
use XML::LibXML; |
| 10 |
# Only methods specific to Processing Instruction nodes are listed here, |
| 11 |
# see the XML::LibXML::Node manpage for other methods |
| 12 |
|
| 13 |
$pinode->setData( $data_string ); |
| 14 |
$pinode->setData( name=>string_value [...] ); |
| 15 |
|
| 16 |
=head1 DESCRIPTION |
| 17 |
|
| 18 |
Processing instructions are implemented with XML::LibXML with read and write |
| 19 |
access. The PI data is the PI without the PI target (as specified in XML 1.0 |
| 20 |
[17]) as a string. This string can be accessed with getData as implemented in L<<<<<< XML::LibXML::Node >>>>>>. |
| 21 |
|
| 22 |
The write access is aware about the fact, that many processing instructions |
| 23 |
have attribute like data. Therefore setData() provides besides the DOM spec |
| 24 |
conform Interface to pass a set of named parameter. So the code segment |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
my $pi = $dom->createProcessingInstruction("abc"); |
| 29 |
$pi->setData(foo=>'bar', foobar=>'foobar'); |
| 30 |
$dom->appendChild( $pi ); |
| 31 |
|
| 32 |
will result the following PI in the DOM: |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
<?abc foo="bar" foobar="foobar"?> |
| 37 |
|
| 38 |
Which is how it is specified in the DOM specification. This three step |
| 39 |
interface creates temporary a node in perl space. This can be avoided while |
| 40 |
using the insertProcessingInstruction() method. Instead of the three calls |
| 41 |
described above, the call |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
$dom->insertProcessingInstruction("abc",'foo="bar" foobar="foobar"'); |
| 46 |
|
| 47 |
will have the same result as above. |
| 48 |
|
| 49 |
L<<<<<< XML::LibXML::PI >>>>>>'s implementation of setData() documented below differs a bit from the standard |
| 50 |
version as available in L<<<<<< XML::LibXML::Node >>>>>>: |
| 51 |
|
| 52 |
=over 4 |
| 53 |
|
| 54 |
=item setData |
| 55 |
|
| 56 |
$pinode->setData( $data_string ); |
| 57 |
$pinode->setData( name=>string_value [...] ); |
| 58 |
|
| 59 |
This method allows one to change the content data of a PI. Additionally to the |
| 60 |
interface specified for DOM Level2, the method provides a named parameter |
| 61 |
interface to set the data. This parameter list is converted into a string |
| 62 |
before it is appended to the PI. |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
=back |
| 67 |
|
| 68 |
=head1 AUTHORS |
| 69 |
|
| 70 |
Matt Sergeant, |
| 71 |
Christian Glahn, |
| 72 |
Petr Pajas |
| 73 |
|
| 74 |
|
| 75 |
=head1 VERSION |
| 76 |
|
| 77 |
2.0134 |
| 78 |
|
| 79 |
=head1 COPYRIGHT |
| 80 |
|
| 81 |
2001-2007, AxKit.com Ltd. |
| 82 |
|
| 83 |
2002-2006, Christian Glahn. |
| 84 |
|
| 85 |
2006-2009, Petr Pajas. |
| 86 |
|
| 87 |
=cut |
| 88 |
|
| 89 |
|
| 90 |
=head1 LICENSE |
| 91 |
|
| 92 |
This program is free software; you can redistribute it and/or modify it under |
| 93 |
the same terms as Perl itself. |
| 94 |
|