| 1 | # -*- tab-width: 4 -*- | ||||||||||
| 2 | # ex: set tabstop=4: | ||||||||||
| 3 | |||||||||||
| 4 | =head1 NAME | ||||||||||
| 5 | |||||||||||
| 6 | XML::TinyXML::Node - Tinyxml Node object | ||||||||||
| 7 | |||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||
| 9 | |||||||||||
| 10 | =over 4 | ||||||||||
| 11 | |||||||||||
| 12 | use XML::TinyXML::Node; | ||||||||||
| 13 | |||||||||||
| 14 | $node = XML::TinyXML::Node->new("child", "somevalue", { attribute => "value" }); | ||||||||||
| 15 | |||||||||||
| 16 | $attr = $node->getAttribute("attribute"); | ||||||||||
| 17 | or | ||||||||||
| 18 | $attr = $node->getAttribute(1); # attribute at index 1 | ||||||||||
| 19 | or | ||||||||||
| 20 | @attrs = $node->getAttributes(); # returns all attributes in the node | ||||||||||
| 21 | |||||||||||
| 22 | =back | ||||||||||
| 23 | |||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||
| 25 | |||||||||||
| 26 | Node representation for the TinyXML API | ||||||||||
| 27 | |||||||||||
| 28 | =head1 INSTANCE VARIABLES | ||||||||||
| 29 | |||||||||||
| 30 | =over 4 | ||||||||||
| 31 | |||||||||||
| 32 | =item * _attr | ||||||||||
| 33 | |||||||||||
| 34 | Reference to the underlying XmlNodeAttributePtr object (which is a binding to the XmlNode C structure) | ||||||||||
| 35 | |||||||||||
| 36 | =back | ||||||||||
| 37 | |||||||||||
| 38 | =head1 METHODS | ||||||||||
| 39 | |||||||||||
| 40 | =over 4 | ||||||||||
| 41 | |||||||||||
| 42 | =cut | ||||||||||
| 43 | |||||||||||
| 44 | package XML::TinyXML::NodeAttribute; | ||||||||||
| 45 | |||||||||||
| 46 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 47 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 48 | |||||||||||
| 49 | 4 | our $VERSION = "0.34"; | |||||||||
| 50 | |||||||||||
| 51 | =item new ($attr) | ||||||||||
| 52 | |||||||||||
| 53 | Wrap the XmlNodeAttributePtr C structure exposing accessor to its members | ||||||||||
| 54 | |||||||||||
| 55 | =cut | ||||||||||
| 56 | 20 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 57 | 20 | my ($class, $attr) = @_; | |||||||||
| 58 | 20 | ▶ | return undef unless(UNIVERSAL::isa($attr, "XmlNodeAttributePtr")); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 20 | my $self = bless({ _attr => $attr }, $class); | |||||||||
| 60 | 20 | return $self; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | =item name ([$newName]) | ||||||||||
| 64 | |||||||||||
| 65 | Get/Set the name of the attribute | ||||||||||
| 66 | |||||||||||
| 67 | =cut | ||||||||||
| 68 | 20 | ▶ | sub name { | ||||||||
|
Subroutine
name: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 69 | 20 | my ($self, $newName) = @_; | |||||||||
| 70 | return defined($newName) | ||||||||||
| 71 | ? $self->{_attr}->name($newName) | ||||||||||
| 72 | 20 | ▶ | : $self->{_attr}->name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | =item value ([$newValue]) | ||||||||||
| 76 | |||||||||||
| 77 | Get/Set the value of the attribute | ||||||||||
| 78 | |||||||||||
| 79 | =cut | ||||||||||
| 80 | 10 | ▶ | sub value { | ||||||||
|
Subroutine
value: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 81 | 10 | my ($self, $newValue) = @_; | |||||||||
| 82 | return defined($newValue) | ||||||||||
| 83 | ? $self->{_attr}->value($newValue) | ||||||||||
| 84 | 10 | ▶ | : $self->{_attr}->value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | =item node (]) | ||||||||||
| 88 | |||||||||||
| 89 | Get the XML::TinyXML::Node to which this attribute belongs | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||
| 92 | 14 | ▶ | sub node { | ||||||||
|
Subroutine
node: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 93 | 14 | my $self = shift; | |||||||||
| 94 | 14 | return XML::TinyXML::Node->new($self->{_attr}->node); | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | =item path () | ||||||||||
| 98 | |||||||||||
| 99 | Returns the unique path identifying this attribute | ||||||||||
| 100 | |||||||||||
| 101 | (can be used in xpath expressions) | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | 0 | ▶ | sub path { | ||||||||
|
Subroutine
path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 105 | 0 | my $self = shift; | |||||||||
| 106 | 0 | return sprintf("%s/\@%s", $self->{_attr}->node->path, $self->name); | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | =item type () | ||||||||||
| 110 | |||||||||||
| 111 | Returns the type of this node | ||||||||||
| 112 | |||||||||||
| 113 | (at the moment it will return always the string : "ATTRIBUTE" | ||||||||||
| 114 | which can be used to distinguish attribute-nodes from xml-nodes | ||||||||||
| 115 | in @sets returned by xpath selections) | ||||||||||
| 116 | |||||||||||
| 117 | =cut | ||||||||||
| 118 | 7 | ▶ | sub type { | ||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 119 | 7 | return "ATTRIBUTE"; | |||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 4 | 1; | |||||||||
| 123 | |||||||||||
| 124 | =back | ||||||||||
| 125 | |||||||||||
| 126 | =head1 SEE ALSO | ||||||||||
| 127 | |||||||||||
| 128 | =over 4 | ||||||||||
| 129 | |||||||||||
| 130 | XML::TinyXML::Node XML::TinyXML | ||||||||||
| 131 | |||||||||||
| 132 | =back | ||||||||||
| 133 | |||||||||||
| 134 | =head1 AUTHOR | ||||||||||
| 135 | |||||||||||
| 136 | xant, E<lt>xant@cpan.orgE<gt> | ||||||||||
| 137 | |||||||||||
| 138 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 139 | |||||||||||
| 140 | Copyright (C) 2008-2010 by xant | ||||||||||
| 141 | |||||||||||
| 142 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 143 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||||||||||
| 144 | at your option, any later version of Perl 5 you may have available. | ||||||||||
| 145 | |||||||||||
| 146 | |||||||||||
| 147 | =cut | ||||||||||