3 XML::LibXML::PI - XML::LibXML Processing Instructions
10 # Only methods specific to Processing Instruction nodes are listed here,
11 # see XML::LibXML::Node manpage for other methods
13 $pinode->setData( $data_string );
14 $pinode->setData( name=>string_value [...] );
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 >>>>>>.
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
28 my $pi = $dom->createProcessingInstruction("abc");
29 $pi->setData(foo=>'bar', foobar=>'foobar');
30 $dom->appendChild( $pi );
32 will result the following PI in the DOM:
36 <?abc foo="bar" foobar="foobar"?>
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
45 $dom->insertProcessingInstruction("abc",'foo="bar" foobar="foobar"');
47 will have the same result as above.
49 L<<<<<< XML::LibXML::PI >>>>>>'s implementation of setData() documented below differs a bit from the the
50 standard version as available in L<<<<<< XML::LibXML::Node >>>>>>:
56 $pinode->setData( $data_string );
57 $pinode->setData( name=>string_value [...] );
59 This method allows 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.
81 2001-2007, AxKit.com Ltd.
83 2002-2006, Christian Glahn.
85 2006-2009, Petr Pajas.