in reply to Re^2: XML::LibXML - WHAR HASH TREES WHAR?!
in thread XML::LibXML - WHAR HASH TREES WHAR?!

Who said LibXML is just a parser?

You, for one.

Yes, probably because it's too old for it.

I meant it can't support namespaces.

I'm not debating that Smart is missing critical functionality.

Neither was I. I was referring to what its design allows.

Are you kidding me?!?! That's a horrible mess!

Are you kidding me? The equivalent would be

$sb->setAttribute(SourceDBType => 'XML') if !$sb->setAttribute('XML');

Incorrect. Smart does both:

Sorry, but that's not working.

use strict; use warnings; use feature qw( say ); use XML::Smart qw( ); my $doc = XML::Smart->new(<<'__EOI__'); <root> <node> a <foo/> b <bar/> c </node> </root> __EOI__ my @children = $doc->{root}{node}[0]('@'); say @children == 5 ? "ok" : "XXX";
1 XXX

Replies are listed 'Best First'.
Re^4: XML::LibXML - WHAR HASH TREES WHAR?!
by SineSwiper (Beadle) on Jul 15, 2011 at 19:48 UTC

    Neither was I. I was referring to what its design allows.

    All the more reason to allow both methods.

    Are you kidding me? The equivalent would be

    $sb->setAttribute('XML') if !$sb->setAttribute('XML');

    Okay, what if it's a node and not an attribute?

    Sorry, but that's not working.

    Sorry, my bad; it should be hash:

    my %children = $doc->{root}{node}[0]('%'); say join "\n", map { "$_ = $children{$_}" } keys %children; say keys %children == 6 ? "ok" : "XXX"; # includes extra "CONTENT" ke +y/value

      Okay, what if it's a node and not an attribute?

      $sb->append(new_data_ele(SourceDBType => 'XML')) if !$sb->findnodes('XML')->size;

      Sorry, my bad; it should be hash:

      Ok, will strike my comment.

      sub child_nodes { my %c = $_[0]('%'); return map { ( my $t = $_ ) =~ s{/CONTENT\K}{}; [ $t => $c{$_} ] } grep $_ ne 'CONTENT', keys %c; }

      It still can't differentiate between elements and attributes, though.

        $sb->append(new_data_ele(SourceDBType => 'XML')) if !$sb->findnodes('XML')->size;

        Okay, but that only checks to see if it found a SourceDBType tag. What if it's blank?

        And I've never even seen a "SourceDBType => 'XML'" syntax. According to the docs, you can define a name and that's it. Hash-based options don't exist at all.