+ $state->{_trigger} = 'Fault';
+ };
+
+=head1 METHODS
+
+=head2 parse
+
+ my $state = CWMP::Request->parse( "<soap>request</soap>" );
+
+=cut
+
+sub parse {
+ my $self = shift;
+
+ my $xml = shift || confess "no xml?";
+
+ $state = {};
+
+ my $parser = XML::Rules->new(
+# start_rules => [
+# '^division_name,fax' => 'skip',
+# ],
+ namespaces => {
+ 'http://schemas.xmlsoap.org/soap/envelope/' => 'soapenv',
+ 'http://schemas.xmlsoap.org/soap/encoding/' => 'soap',
+ 'http://www.w3.org/2001/XMLSchema' => 'xsd',
+ 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi',
+ 'urn:dslforum-org:cwmp-1-0' => '',
+ },
+ rules => $rules,
+ );
+
+# warn "## created $parser\n";
+
+ $parser->parsestring( $xml );
+
+ undef $parser;
+
+ if ( my $trigger = $state->{_trigger} ) {
+ warn "### call_trigger( $trigger )\n";
+ $self->call_trigger( $trigger, $state );
+ }
+ # XXX propagate _trigger (useful for symlinks)
+
+ return $state;
+}
+
+=head2 _tag
+
+Get value of tag. Tag name is case insensitive (don't ask why),
+we ignore namespaces and can take optional C<sub_key>
+(usually C<_content>).
+
+ _tag( $tag_hash, $name, $sub_key )
+
+=cut
+
+sub _tag {
+ my ( $tag_hash, $name, $sub_key ) = @_;
+ confess "need hash as first argument" unless ( ref $tag_hash eq 'HASH' );
+ $name = (grep { m/^(?:\w+:)*$name$/i } keys %$tag_hash )[0];
+# $name =~ s/^\w+://;
+ if ( defined $tag_hash->{$name} ) {
+ if ( ! defined $sub_key ) {
+ return $tag_hash->{$name};
+ } elsif ( defined $tag_hash->{$name}->{$sub_key} ) {
+ return $tag_hash->{$name}->{$sub_key};
+ } else {
+ return if ( $name =~ m/^value$/i );
+ warn "can't find '$name/$sub_key' in ", dump( $tag_hash );
+ return;