https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7170
M. Tompsett <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #19 from M. Tompsett <[email protected]> --- I was looking in the svc ones and came up with this hackiness. sub build_xml_output { my ($xml_hash, $root_name) = @_; my @xml_tags = keys %{$xml_hash}; my @values = map { { 'key' => $_, 'value' => $xml_hash->{$_} } } @xml_tags; my $xml_values; foreach my $value (@values) { $xml_values->{$value->{key}} = $value->{value}; } my $dom = XML::LibXML::Document->new( '1.0', q{} ); $dom->setStandalone(1); my $root = $dom->createElement( $root_name ); $dom->setDocumentElement( $root ); foreach my $xml_tag (@xml_tags) { my $xml_value = $xml_values->{$xml_tag}; my $text = $dom->createTextNode( "\n " ); $root->appendChild($text); my $element = $dom->createElement( $xml_tag ); $root->appendChild($element); if ($xml_value =~ /\<datafield/ ) { my $parser = XML::LibXML->new(); my $fragment = $parser->parse_balanced_chunk( $xml_value ); $element->appendChild( $fragment ); } else { $text = $dom->createTextNode( $xml_value ); $element->appendTextNode($text); } } my $text = $dom->createTextNode( "\n" ); $root->appendChild($text); my $xml_output = $dom->toString(0); print $xml_output; } You can see why XML::Simple with its XMLout method is desirable. :) -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
