my $rslt = $res->content;
# OpenSRS renew response triggers Expat parser error due to spaces in element name
$rslt =~ s/registration expiration date/registration_expiration_date/g;
- eval { $struct = XML::Simple::XMLin( $rslt ); };
+
+ eval { $struct = XML::Simple::XMLin(
+ $rslt,
+ 'KeyAttr' => [ 'dt_assoc' ],
+ 'GroupTags' => { 'dt_assoc' => 'item', 'dt_array' => 'item' },
+ );
+ };
if ($self->debug_level > 1) {
$self->debug("\nOpenSRS Response XML:\n" . '-' x 30);
# get the struct looking just how we want it.
# (de-nastify it.)
- $xml = XML::Simple::XMLout( $struct->{body}->{data_block}->{dt_assoc}->{item} );
- $struct = XML::Simple::XMLin( $xml );
- $xml = XML::Simple::XMLout( $struct->{attributes}->{item} );
- $struct->{attributes} = XML::Simple::XMLin( $xml );
+ (undef, $struct) = _denastify( $struct->{body}->{data_block} );
}
else {
$self->debug("HTTP error: " . $res->status_line);
return $xml;
}
+sub _denastify {
+ my ($arg) = ( shift );
+ if ( ref($arg) eq 'HASH' ) {
+ my $value;
+ if ( exists( $arg->{content} ) ) {
+ $value = $arg->{content};
+ } elsif ( exists( $arg->{dt_array} ) ) {
+ $value = [ map {
+ { map { _denastify($_) } @{ $_->{dt_assoc} } }
+ }
+ @{ $arg->{dt_array} }
+ ];
+ } elsif ( exists( $arg->{dt_assoc} ) ) {
+ $value = { map { _denastify($_) } @{ $arg->{dt_assoc} } };
+ }
+ return ( $arg->{key} => $value );
+ }
+ ();
+}
+
=back
=head1 Author